RelativeLayout可以设置某一个视图相对于其他视图的位置,这些位置可以包括上下左右等。
android:layout_below 在某个元素(控件的下方)
android:layout_above 在某个元素的上方
android:layout_toLeftOf 在某个元素的左边
android:layout_toRight 在某个元素的右边

下面是一个用相对布局写的QQ登录界面的代码(附效果图)

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"     >    <ImageView         android:id="@+id/iv_icon"        android:layout_width="100dp"        android:layout_height="100dp"        android:src="@drawable/yingjie"        />    <EditText         android:id="@+id/et_account"        android:layout_width="180dp"        android:layout_height="wrap_content"        android:text="账号"        android:layout_toRightOf="@id/iv_icon"        />          <EditText         android:id="@+id/et_password"        android:layout_width="180dp"        android:layout_height="wrap_content"        android:text="密码"        android:layout_toRightOf="@id/iv_icon"        android:layout_below="@id/et_account"        />            <TextView           android:id="@+id/tv_regisster"          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:text="注册账号"          android:layout_toRightOf="@id/et_account"          android:layout_marginTop="18dp"          />             <TextView           android:id="@+id/returnPassword"          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:text="找回密码"          android:layout_toRightOf="@id/et_password"          android:layout_marginTop="44dp"          />       <CheckBox            android:id="@+id/cb_markPassword"           android:layout_width="wrap_content"           android:layout_height="wrap_content"           android:layout_below="@id/et_password"           android:layout_toRightOf="@id/iv_icon"           android:text="记住密码"           />       <CheckBox            android:id="@+id/cb_autoLogin"           android:layout_width="wrap_content"           android:layout_height="wrap_content"           android:layout_below="@id/et_password"           android:layout_toRightOf="@id/cb_markPassword"           android:text="自动登录"           />       <Button            android:id="@+id/btn_login"           android:layout_width="match_parent"           android:layout_height="wrap_content"           android:text="登录"           android:layout_below="@id/cb_autoLogin"           />RelativeLayout>

相对布局(RelativeLayout)写的QQ登录界面_第1张图片

更多相关文章

  1. Android Layout XML属性 及 控件属性
  2. Android UI设计——ImageView和ImageButton控件
  3. Android中常用基本控件的使用方法和步骤(.txt)
  4. Android UI设计——ListView控件与SimpleAdapter适配器(三)
  5. 移动web在ios和android下点击元素出现阴影问题
  6. 浅谈Android常用控件
  7. Android 自定义控件实现刮刮卡效果 真的就只是刮刮卡么
  8. Android shap 控件美化
  9. [Android] ListView (普通列表控件) 的基本使用方法

随机推荐

  1. Android线程优先级规定及其设置的具体方
  2. Windows及Android倍速播放视频软件下载
  3. Android中pendingIntent的深入理解
  4. Android(安卓)NDK开发之旅38--FFmpeg视频
  5. Android(安卓)ContentProvider基础
  6. Android(安卓)利用 Webservice 获取手机
  7. Android(安卓)性能优化:多线程
  8. AndroidPN真机环境测试
  9. android 动画 ——视图动画(View Animati
  10. AndroidStudio快捷键整理--3