一、基本控件
1、标签控件(TextView)
- 常用属性:text、textSize、textColor……
2、编辑框控件(EditText)
- 常用属性:text、textSize、textColor、hint……
3、按钮控件(Button)
- 常用属性:text、background、layout_width、layout_height……
二、知识点
- 线性布局(LinearLayout)
- 标签(TextView)
- 编辑框(EditText)
- 按钮(Button)
- 安卓事件处理机制(Event Handling Mechanism)
- 吐司(Toast)
三、创建安卓应用
四、添加背景图片
最好添加两张背景图片(一张用于登录与注册,第二张用于实现跳转页面)
将背景图片放在res/drawable目录
五、基于模板创建登录窗口
用于页面跳转实现的窗口
六、登录窗口布局资源文件
<?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:gravity="center"
android:orientation="vertical"
android:background="@drawable/tt"
tools:context=".Loginu">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="400dp"
android:layout_weight="2"
android:gravity="bottom"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_user_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/user_login"
android:textColor="#9C27B0"
android:textSize="35dp">
</TextView>
</LinearLayout>>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="5"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:id="@+id/tvusername"
android:layout_width="90dp"
android:layout_height="60dp"
android:ems="5"
android:gravity="center"
android:text="@string/username"
android:textSize="20dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="60dp"
android:singleLine="true"
android:id="@+id/edt_username"
android:ems="10"
android:hint="@string/input_username"
android:inputType="textPersonName"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="5"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_password"
android:layout_width="90dp"
android:layout_height="60dp"
android:ems="10"
android:gravity="center"
android:text="@string/password"
android:textSize="20dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="60dp"
android:id="@+id/edt_password"
android:ems="10"
android:hint="@string/input_password"
android:singleLine="true"
android:inputType="textPassword"
/>
</LinearLayout>
<LinearLayout
android:layout_width="230dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:gravity="center_horizontal"
android:orientation="horizontal">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/custom_border"
android:hint="登录"
android:textColor="#130908"
android:textSize="25dp"
/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:background="@drawable/custom_border"
android:hint="取消"
android:textColor="#130908"
android:textSize="25dp" />
</LinearLayout>
</LinearLayout>
七、布局资源文件
<?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:background="@drawable/flow"
android:orientation="vertical"
android:padding="23dp"
tools:context=".User">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvusername"
android:layout_marginTop="10dp"
android:textColor="@color/colorAccent"
android:textSize="25dp"/>
</LinearLayout>
八、字符串资源文件strings.xml
<resources>
<string name="app_name"