先看一下登录界面。

本文章就是给初学者一个例子。

本例子使用RelativeLayout布局标签

现在上代码

 1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2     xmlns:tools="http://schemas.android.com/tools" 3     android:layout_width="fill_parent" 4     android:layout_height="fill_parent" 5     android:orientation="vertical" 6     android:padding="10px"> 7          8         <TextView android:layout_width="wrap_content" 9                       android:layout_height="wrap_content"10                       android:id="@+id/tx_username"11                       android:text="@string/tx_username"/>12         13         <EditText android:layout_width="fill_parent"14                   android:layout_height="wrap_content"15                   android:background="@android:drawable/editbox_background"16                   android:layout_below="@id/tx_username"17                   android:id="@+id/UserName"/>18         19         <TextView android:layout_width="wrap_content"20                       android:layout_height="wrap_content"21                       android:layout_below="@id/UserName"22                       android:id="@+id/tx_password"23                       android:text="@string/tx_password"/>24         25         <EditText android:layout_width="fill_parent"26                       android:layout_height="wrap_content"27                       android:inputType="textWebPassword"28                       android:background="@android:drawable/editbox_background"29                       android:layout_below="@id/tx_password"30                       android:id="@+id/PassWord"/>31         32         <CheckBox33                 android:id="@+id/Remember_PassWord"34                 android:layout_width="wrap_content"35                 android:layout_height="wrap_content"36                 android:layout_alignParentLeft="true"37                 android:layout_below="@id/PassWord"38                 android:text="@string/tx_remember_password" />39         40         <Button41                 android:id="@+id/Login"42                 android:layout_width="wrap_content"43                 android:layout_height="wrap_content"44                 android:layout_gravity="center_horizontal"45                 android:layout_below="@id/PassWord"46                 android:layout_alignParentRight="true"47                 android:text="@string/tx_login" />48         49 </RelativeLayout>

大概说一下,首先RelativeLayout是相对布局,其中的每个空间都用到了相对布局的标签

1、android:layout_below="@id/tx_username" 意思是:这个控件的顶部,在id为tx_username的下面;

2、android:layout_alignParentLeft="true" 意思是:这个控件,紧贴父控件的右侧;

3、android:padding="10px" 意思是:内边距为10px;

更多相关文章

  1. android用户界面之按钮(Button)教程实例汇
  2. android五种布局模式
  3. Android编程示例之——横竖屏切换动画
  4. Android(安卓)调用相册 拍照 实现系统控件缩放 切割图片
  5. Android控件开发之四----ListView(1)
  6. Android控件开发
  7. android:自己实现能播放网络视频url的播放器
  8. android 经典文章收集
  9. 了解使用Android(安卓)ConstraintLayout

随机推荐

  1. 实用的银行转账存储过程和流水号生成存储
  2. sql server代理中作业执行SSIS包失败的解
  3. SQL Server数据库中批量导入数据的2种方
  4. 浅谈基于SQL Server分页存储过程五种方法
  5. SQL Server数据汇总五招轻松搞定
  6. 如何监测和优化OLAP数据库
  7. java 连接sql server2008数据库配置
  8. 详解SQLServer和Oracle的分页查询
  9. win10安装Sql Server 2014图文教程
  10. SQL SERVER数据库表记录只保留N天图文教