Android-------模拟用户登录界面(优化1)
2015-04-17 16:07
489 查看
当基本的界面设置完成之后,我对基本界面做了一些简单的优化,使得看起来更加的美观和舒服。
一、边角框的使用
新建一个xml文件:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- <solid android:color="#FFFFFF" /> -->//这里设置自定义的颜色。本例使用#FFFFFF,如果为空则为透明
<corners android:topLeftRadius="2dp"
android:topRightRadius="2dp"
android:bottomRightRadius="2dp"
android:bottomLeftRadius="2dp"/>
<!-- 解释:solid的表示填充颜色,为了简单,这里用的是黑色。
而corners则是表示圆角,注意的是这里bottomRightRadius是左下角而不是右下角,bottomLeftRadius右下角。
当然上面的效果也可以像下面一样设置,如下:
<corners android:radius="5dp" />
如果想引用这个xml,只需要@drawable/corners_bg.xml即可:
android:background="@drawable/corners_bg" -->
</shape>
然后在activity_main.xml中设置:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:background="@drawable/background">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp">
<TableRow
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户名"/>
<EditText
android:id="@+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:hint="请输入用户名"/>"
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码"/>
<EditText
android:id="@+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:hint="请输入密码"
android:inputType="textPassword"/>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认密码"/>
<EditText
android:id="@+id/RePwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:hint="请再次输入密码"
android:inputType="textPassword"/>"
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="性别"/>
<RadioGroup
android:id="@+id/sex"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="男"/><!-- 检查时候被选中 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "/>
<RadioButton
android:id="@+id/famle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="女"/>"
</RadioGroup>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="来自"/>
<Spinner
android:id="@+id/from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="邮箱地址"/>
<EditText
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:inputType="textEmailAddress"/>"
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="邮箱通知"/>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ToggleButton
android:id="@+id/notify"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ToggleButton"/>"
</FrameLayout><!-- 叠加的方式http://www.cnblogs.com/zhangs1986/archive/2013/01/17/2864899.html -->
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="10dp">
<CheckBox
android:id="@+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="同意条款"/>
<!-- http://www.cnblogs.com/wt616/archive/2011/06/20/2085368.html -->
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
>
<Button
android:id="@+id/btn_Regster"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:text="注册"/>
<Button
android:id="@+id/btn_Cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:layout_marginLeft="20dp"
android:text="取消"/>"
</LinearLayout>
</LinearLayout>
并添加了一张背景图片,如图:
设置了一下桌面的小图标:
如图:
设置的位置是:Androidmanifest.xml
中的:<application
android:allowBackup="true"
android:icon="@drawable/ic_luncher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="ResultActivity"></activity><!--这里注意要把你的第二个activity写进去,因为Android系统首先加载的就是Androidmanifest.xml文件-->
</application>
一、边角框的使用
新建一个xml文件:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- <solid android:color="#FFFFFF" /> -->//这里设置自定义的颜色。本例使用#FFFFFF,如果为空则为透明
<corners android:topLeftRadius="2dp"
android:topRightRadius="2dp"
android:bottomRightRadius="2dp"
android:bottomLeftRadius="2dp"/>
<!-- 解释:solid的表示填充颜色,为了简单,这里用的是黑色。
而corners则是表示圆角,注意的是这里bottomRightRadius是左下角而不是右下角,bottomLeftRadius右下角。
当然上面的效果也可以像下面一样设置,如下:
<corners android:radius="5dp" />
如果想引用这个xml,只需要@drawable/corners_bg.xml即可:
android:background="@drawable/corners_bg" -->
</shape>
然后在activity_main.xml中设置:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:background="@drawable/background">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp">
<TableRow
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户名"/>
<EditText
android:id="@+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:hint="请输入用户名"/>"
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码"/>
<EditText
android:id="@+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:hint="请输入密码"
android:inputType="textPassword"/>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认密码"/>
<EditText
android:id="@+id/RePwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:hint="请再次输入密码"
android:inputType="textPassword"/>"
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="性别"/>
<RadioGroup
android:id="@+id/sex"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="男"/><!-- 检查时候被选中 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "/>
<RadioButton
android:id="@+id/famle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="女"/>"
</RadioGroup>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="来自"/>
<Spinner
android:id="@+id/from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="邮箱地址"/>
<EditText
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:inputType="textEmailAddress"/>"
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="邮箱通知"/>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ToggleButton
android:id="@+id/notify"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ToggleButton"/>"
</FrameLayout><!-- 叠加的方式http://www.cnblogs.com/zhangs1986/archive/2013/01/17/2864899.html -->
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="10dp">
<CheckBox
android:id="@+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="同意条款"/>
<!-- http://www.cnblogs.com/wt616/archive/2011/06/20/2085368.html -->
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
>
<Button
android:id="@+id/btn_Regster"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:text="注册"/>
<Button
android:id="@+id/btn_Cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/corner"
android:layout_marginLeft="20dp"
android:text="取消"/>"
</LinearLayout>
</LinearLayout>
并添加了一张背景图片,如图:
设置了一下桌面的小图标:
如图:
设置的位置是:Androidmanifest.xml
中的:<application
android:allowBackup="true"
android:icon="@drawable/ic_luncher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="ResultActivity"></activity><!--这里注意要把你的第二个activity写进去,因为Android系统首先加载的就是Androidmanifest.xml文件-->
</application>
相关文章推荐
- Android-------模拟用户登录界面(1)
- Android-------模拟用户登录界面(3)
- Android-------模拟用户登录界面(5)
- Android-------模拟用户登录界面(2)
- Android-------模拟用户登录界面(4)
- Android登录界面之用户数据保存+服务器上传
- 【Android】用户登录注册界面开发及用户信息管理案例代码详解
- Google用户登录界面 Android实现
- 使用Struts2框架搭建Android服务器,模拟用户登录
- Android用户登录注册界面开发及用户信息管理案例代码详解
- 【Android】用户登录注册界面开发及用户信息管理案例代码详解
- Android-UI:用户登录界面
- Android-数据储存:用户登录界面(存储)
- Android 用户登录界面
- Android(Java) 模拟登录知乎并抓取用户信息
- 【Android】用户登录注册界面开发及用户信息管理案例代码详解
- Android(Java) 模拟登录知乎并抓取用户信息
- Android(Java) 模拟登录知乎并抓取用户信息
- Android 基本控件的使用一(用户的登录界面)
- 【Android】用户登录注册界面开发及用户信息管理案例代码详解