Android Studio入门级UI界面设计(图文+解析)
来源: 网络
时间: 2022-06-15
阅读:
下面配上本次试验UI界面
- 1.首先设置成线性布局,添加orientation属性,设置成垂直
android:orientation="vertical"
- 设置padding为8dp(Padding 为内边框,指该控件内部内容,如文本/图片距离该控件的边距)
android:padding="8dp"
- 2.创建一个testview写标题
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="帐号登陆"
android:textSize="40dp"/>
标题字体大小 40dp(android:textSize=“40dp”)java
-3. 创建两个editview,输入框
要让Edittext单行显示android
android:maxLines="1"
限制显示文本长度,超出不显示web
android:maxLength="10"
文本为空时候显示的文本svg
android:hint="请输入你的帐号(最多十个字符)"
文本过长时,省略号显示在结尾布局
android:ellipsize="end"
距离顶部的距离字体
android:layout_marginTop="80dp"
-4. 创建登陆按钮,button
android:layout_gravity是用来设置该view相对与父view 的位置.好比一个button 在linearlayout里,你想把该button放在linearlayout里靠左、靠右等位置就能够经过该属性设置spa
android:layout_gravity="center"
-5. 添加一个相对布局RelativeLayout,在里面创建CheckBox控件
<CheckBox
android:id="@+id/cb_rm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="记住密码"
android:textSize="18dp"
/>
-6.再在里面创建一个testview(忘记密码)
<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" />
将控件的右边缘和父控件的右边缘对齐.net
android:layout_alignParentRight="true"
将控件置于垂直方向的中心位置3d
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>
下一篇 :没有了,点击返回