`
myclover
  • 浏览: 191243 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

android常用UI控件的使用例子

阅读更多
之前有几个好朋友说最近android很火,很想学习下android,在他们的要求下,我给他们讲解了android的一些基础知识,带他们进入android的大门,以下是讲解课程中的第二课,常用UI控件的使用,第一课主要是android的一些简单介绍和环境的搭建,这个可以参考我之前的环境搭建的文章,这些都是比较基础的东西,对初学者有帮助而已,大虾们就不需要浪费时间了。以下这个xml文件中是包含了该课程中的全部UI控件了。

register.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
	xmlns: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>
	 <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/sexLable"
			android:id="@+id/sexLable"
			android:textColor="@drawable/magenta"
			/>
		<RadioGroup
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:layout_toRightOf="@id/sexLable"
			android:layout_marginLeft="15px"
			android:layout_alignTop="@id/sexLable"
			>
			<RelativeLayout
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				>
				<RadioButton
					android:layout_width="70px"
					android:layout_height="wrap_content"
					android:id="@+id/male"
					android:text="@string/maleLable"
					android:checked="true"
					android:textStyle="italic"
					/>
				<RadioButton
					android: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>

分享到:
评论

相关推荐

    android3.0新增UI控件示例说明

    android3.0新增UI控件示例说明android3.0新增UI控件示例说明

    Android的29个常用UI示例

    Android的29个常用UI示例,全部可执行,代码注释详细。

    Android 3.0新增UI控件示例说明.rar

    Android 3.0新增UI控件示例说明.rar

    Android图形界面基本UI控件示例

    基本控件的使用:1.TextView、EditText2. Button3.ListView4.Toggle5.RadioBtn6.CheckBox7.Spinner8.Clock9.Picker

    Android自定义view组合控件、重写控件的例子源码.rar

    Android自定义view组合控件、重写控件的例子源码,创建出对应的组合布局视图,将创建出的视图添加到根节点。Android使用view控件的例子,面向Android开发新手,高手绕行。

    android 自定义控件入门的例子源码

    这是我写的 Android 自定义控件入门 这个小教程的例子源码,十分基础,用了同一个例子的不同写法和扩展,简单明了的讲解了View的重写,教程请去我的博客,地址为:...希望大家能通过简单的例子学到东西,举一反三。...

    android简单注册UI布局

    注册 android布局 UI控件 非常简单的例子

    浅谈Android RecyclerView UI的滚动控件示例

    ListView 由于其强大的功能,在过去的 Andorid 开发中使用非常广泛。... RecyclerView 现在可是官方推荐使用的滚动控件哦O(∩_∩)O~ 1 基本用法 RecyclerView 也是新增的控件,所以必须先在项目的 build.gradle 中添

    尚硅谷Android视频教程《自定义控件》

    教程名称: 尚硅谷Android视频教程《自定义控件》Android自定义控件,是中高级程序员必须熟练掌握的技术之一。本套视频涵盖了安卓自定义开发过程中所有的技术问题,课程中讲授的例子全部来源于企业。学习本套视频后...

    Android BOOK源码实现Android所有的UI控件

    摘要:Java源码,Android源码,UI控件 Android BOOK源码实例,让你看遍所有UI控件,一个例子实现了Android 里面所有的UI控件,对编写Android UI界面来说,绝对是不容错过的Android参考源码

    几款Android Calendar日历控件的实现范例.rar

    主要是演示介绍了CalendarView日历控件的使用虽然日历控件在Web开发中有很多的解决方案,而且容易实现,但是在Android平台上的解决方案较少,源码目录中与大家分享了几款实现Calendar的示例,并附有实现这几款控件的...

    Android UI 中的 ListView列表控件的示例

    本篇文章主要介绍了Android UI 中的 ListView列表控件的示例,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

    Android-samples:此存储库用于存储Telerik UI for Android套件的所有控件的示例

    在这里,您可以找到适用于Android组件的所有UI的SDK使用示例。 您还可以找到在Google Play商店中看到的Android演示应用程序UI的源代码: : Android UI入门 Android组件的UI的SDK示例可在Samples-Java文件夹中找到...

    android基本控件基本动画代码(供初学者学习用)

    一个demo,包括了android UI 基本控件的使用,基本的动画效果, 存储,服务等功能的简单实现。 在大家学习的过程中,可以作为参考的示例代码。

    Android各种控件

    大家都知道Android有很多UI控件,最常见的如Textview,Button,再到recyclerview等等一些控件,这个例子将他们放在一起,并给相应的例子

    Android UI设计:打造美观界面的完整Demo 源码

    2. **控件使用**:展示了如何使用Android提供的标准控件,如按钮、文本框、列表等,并对其进行样式定制。 3. **主题和样式**:解释了如何通过定义主题和样式来统一和美化应用的UI。 4. **图形和动画**:探讨了如何...

    Android基础课内实验报告.doc

    掌握Android常见UI控件的特征、属性; 2. 掌握Android常见UI控件的事件处理机制; 3. 掌握如何用Android常见的UI可视化数据; 4. 学会使用基本的UI控件编写程序。 实验内容: 内容1:参考教材P92的Spinner使用示例...

    Android UI设计:为ListView添加圆角边框效果.rar

    Android为ListView添加圆角边框效果,安卓UI设计的例子,默认情况下ListView的外框是直角的,也就是大家习惯的样式,但为了美化更突出,或者与你的应用风格更吻合,有时候可能修饰成圆角边框,本例子就是实现了这一...

Global site tag (gtag.js) - Google Analytics