android常用UI控件的使用例子
16lz
2021-01-23
之前有几个好朋友说最近android很火,很想学习下android,在他们的要求下,我给他们讲解了android的一些基础知识,带他们进入android的大门,以下是讲解课程中的第二课,常用UI控件的使用,第一课主要是android的一些简单介绍和环境的搭建,这个可以参考我之前的环境搭建的文章,这些都是比较基础的东西,对初学者有帮助而已,大虾们就不需要浪费时间了。以下这个xml文件中是包含了该课程中的全部UI控件了。
register.xml
register.xml
<?xml version="1.0" encoding="utf-8"?><ScrollViewxmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" ><LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/nameLable" android:id="@+id/nameLable" android:textColor="@drawable/red" /> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/nameLable" android:layout_marginLeft="45px" android:id="@+id/name" android:maxLength="30" /> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/pwdLable" android:id="@+id/pwdLable" android:textColor="@drawable/white" /> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/pwdLable" android:layout_marginLeft="45px" android:id="@+id/pwd" android:password="true" /> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/cfmpwdLable" android:id="@+id/cfmpwdLable" android:textColor="@drawable/other" /> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/cfmpwdLable" android:layout_marginLeft="17px" android:id="@+id/cfmpwd" android:password="true" /> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/emailLable" android:id="@+id/emailLable" android:textColor="@drawable/gray" /> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/emailLable" android:layout_marginLeft="45px" android:id="@+id/email" android:autoLink="email" /> </RelativeLayout> <RelativeLayoutandroid:layout_width="fill_parent"android:layout_height="wrap_content"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/sexLable"android:id="@+id/sexLable"android:textColor="@drawable/magenta"/><RadioGroupandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_toRightOf="@id/sexLable"android:layout_marginLeft="15px"android:layout_alignTop="@id/sexLable"><RelativeLayoutandroid:layout_width="fill_parent"android:layout_height="wrap_content"><RadioButtonandroid:layout_width="70px"android:layout_height="wrap_content"android:id="@+id/male"android:text="@string/maleLable"android:checked="true"android:textStyle="italic"/><RadioButtonandroid:layout_width="80px"android:layout_height="wrap_content"android:layout_toRightOf="@id/male"android:id="@+id/female"android:layout_alignTop="@id/male"android:text="@string/femaleLable"android:textStyle="italic"/></RelativeLayout></RadioGroup></RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/birthdayLable" android:id="@+id/birthdayLable" android:textColor="@drawable/ltgray" /> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/birthdayLable" android:layout_marginLeft="15px" android:id="@+id/birthday" android:singleLine="true" android:clickable="true" /> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/degreeLable" android:id="@+id/degreeLable" android:textColor="@drawable/green" /> <Spinner android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/degreeLable" android:layout_marginLeft="15px" android:id="@+id/degree" /> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/skillLable" android:id="@+id/skillLable" android:textColor="@drawable/dkgray" android:textStyle="bold" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/skillLable" android:layout_marginLeft="15px" android:text="java" android:id="@+id/java" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/java" android:layout_marginLeft="15px" android:id="@+id/j2ee" android:text="j2ee" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/j2ee" android:layout_marginLeft="15px" android:id="@+id/android" android:text="android" /> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/remarkLable" android:id="@+id/remarkLable" android:background="@drawable/yellow" /> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/remarkLable" android:layout_marginLeft="15px" android:id="@+id/remark" android:minLines="3" /> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/submitBtn" android:layout_marginLeft="50px" android:src="@drawable/selectcity" android:tag="@string/submitBtn" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/resetBtn" android:layout_toRightOf="@id/submitBtn" android:layout_marginLeft="30px" android:text="@string/resetBtn" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/backBtn" android:layout_toRightOf="@id/resetBtn" android:layout_marginLeft="30px" android:text="@string/backBtn" /> </RelativeLayout> </LinearLayout> </ScrollView>
更多相关文章
- Android 安装环境搭建
- Android控件常用属性
- 跟着Android官方培训课程学习,挖坑填坑记录
- android中控件的遮盖问题
- android环境搭建步骤
- Android中的多媒体编程-黄俊东-专题视频课程
- Android在Eclipse环境下安装配置
- [置顶] android Studio 配置LUA 开发环境