Android一个登陆界面的设计
Android一个登陆界面的设计
说起登陆界面的设计,大家可能都会说这个挺简单的的啊,弄个布局,加几个控件一个登陆界面就出来了,但我今天想说一下自己在设计一个登陆界面时遇到的问题,而我这个登陆界面的设计重点就是在一个水平布局上放了一个checkbox和一个登陆的button,在checkbox放上之后,之后的那个button在这个水平布局的空余空间上居中,这个对于高手来说可能不是什么问题了,而让我奇怪的是当我的布局属性设置为水平时,我的登陆button并不能居中,而只有在垂直的属性下button才能居中。
所以现在把这个代码贴出来,界面的效果并没有做什么美化,只是一些系统控件的组合。
选看一下效果图:
所以这个设计的重点也就是在红色区域里让button居中。
下面是改布局的xml文件
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
- <LinearLayout android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="账号:"/>
- <EditText android:layout_width="240dip"
- android:layout_height="wrap_content"
- android:text="mumayi"
- android:id="@+id/edtuser"/>
- </LinearLayout>
- <LinearLayout android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="密码:"/>
- <EditText android:layout_width="240dip"
- android:layout_height="wrap_content"
- android:password="true"
- android:id="@+id/edtpsd"/>
- </LinearLayout>
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="horizontal" >
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
- <CheckBox
- android:id="@+id/checkbox"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="记住密码" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
- <Button
- android:id="@+id/login"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"
- android:text="登录" />
- </LinearLayout>
- </LinearLayout>
- </LinearLayout>
评论暂时关闭