每天一个小目标,你会变得很强大。
先上只用LinerarLayout布局完成一个登陆界面,效果图以及蓝图奉上:
所有的布局以及控件都是景观的子类。
先来点取景功能类常用的属性:
属性 | 含义 |
机器人:背景 | 设置背景 |
机器人:点击 | 设置查看是否响应单击事件 |
机器人:可见 | 控制视图的可见性 |
机器人:可聚焦 | 控件查看是否可以焦点电子杂志 |
机器人:ID | 为视图设置标识符,可通过findViewById 方法获取 |
再来点的的ViewGroup中的常用属性(的ViewGroup中为视图的子类):
属性 | 含义 |
机器人:layout_height | 指定该子组件的布局高度 |
机器人:layout_width | 指定该子组件的布局宽度 |
详细代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView"
android:background="#fff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录"/>
</LinearLayout>
<LinearLayout
android:background="#fff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="手机号"/>
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="密码"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/signin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#fff"
android:text="注册"
/>
<Button
android:layout_marginLeft="200dp"
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
代码中的按钮,TextView的的的,的的EditText上为常用的控件,这里只需照敲即可,我会在后续的教程中逐步为大家讲解。
到这里就完成啦,继续努力学习中,如有问题欢迎提问。奋斗小青年GO!....