- android:orientation="vertical"
-
- android:padding="8dp"
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="账号登录"
- android:textSize="40dp"/>
-
标题字体大小 40dp(android:textSize=“40dp”)
要让Edittext单行显示
- android:maxLines="1"
-
限制显示文本长度,超出不显示
- android:maxLength="10"
-
文本为空时候显示的文本
- android:hint="请输入你的账号(最多十个字符)"
-
文本过长时,省略号显示在结尾
- android:ellipsize="end"
-
距离顶部的距离
- android:layout_marginTop="80dp"
-
android:layout_gravity是用来设置该view相对与父view 的位置.比如一个button 在linearlayout里,你想把该button放在linearlayout里靠左、靠右等位置就可以通过该属性设置
- android:layout_gravity="center"
-
- <CheckBox
- android:id="@+id/cb_rm"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="记住密码"
- android:textSize="18dp"
- />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:text="忘记密码"
- android:textColor="#9E2222"
- android:layout_centerVertical="true"
- android:textSize="18dp" />
-
将控件的右边缘和父控件的右边缘对齐
- android:layout_alignParentRight="true"
-
将控件置于垂直方向的中心位置
- android:layout_centerVertical="true"
-
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:padding="8dp"
- android:background="#F8F7F7">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="账号登录"
- android:textSize="40dp"/>
- <EditText
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="请输入你的账号(最多十个字符)"
- android:id="@+id/et_username"
- android:layout_marginTop="80dp"
- android:textColor="#9ACCA7"
- android:maxLines="1"
- android:ellipsize="end"
- android:maxLength="10"/>
- <EditText
- android:id="@+id/et_pw"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="请输入你的密码"
- android:layout_marginTop="10dp"
- android:textColor="#DAC3E0"
- android:maxLines="1"
- android:ellipsize="end"/>
- <Button
- android:layout_marginTop="25dp"
- android:layout_width="300dp"
- android:layout_height="60dp"
- android:text="登录"
- android:textSize="25dp"
- android:layout_gravity="center"/>
- <RelativeLayout
- android:layout_marginTop="50dp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <CheckBox
- android:id="@+id/cb_rm"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="记住密码"
- android:textSize="18dp"/>
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:text="忘记密码"
- android:textColor="#9E2222"
- android:layout_centerVertical="true"
- android:textSize="18dp" />
- </RelativeLayout>
- </LinearLayout>
-