实训二 Android 基本组件(布局)
实训要求:
掌握相对布局的常用 XML 属性
掌握线性布局的常用 XML 属性
实训内容:
1、 使用相对布局结合 TextView 和 EditText、Button 完成用户登录界面的设计
2、 为登录按钮添加事件处理,判断用户是否等于 abc,完成对简单的登录事件的处理
实训步骤与代码:
1、 使用相对布局的方式对组件进行布局,布局文件的内容如下
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
>
<TextView
android:id="@+id/ts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/login"
style="@style/txt"
android:autoLink="phone|email|web"
/>
<EditText
android:id="@+id/in"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/ts"
android:inputType="text"
/>
<Button
android:id="@+id/cancel"
android:layout_width="wrap_content"
评论0
最新资源