RelativeLayout(相对布局)

Android:layout_below将当前控件的上边沿对齐到所指定Id控件的下边沿

Android:layout_alignParentRight=”true”对齐到父控件的右边

Android:layout_centerInParent对齐到父控件的中央

<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

>

<TextView

android:id="@+id/worldView"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#00FF11"

android:text="@string/hello_world"/>

<!--将当前控件的上边沿对齐到所指定Id控件的下边沿-->

<TextView

android:id="@+id/sayView"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#FF1122"

android:layout_below="@id/worldView"

android:text="sayhello"

/>

</RelativeLayout>

<!--将当前控件的右边沿对齐ID所指控件的右边沿-->

<TextView

android:id="@+id/sayView"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#FF1122"

android:layout_alignRight="@id/worldView"

android:text="sayhello"

/>

基准线(baseline)

<!--对齐到基准线-->

<TextView

android:id="@+id/sayView"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:textSize="15sp"

android:background="#FF1122"

android:layout_alignBaseline="@id/worldView"

android:layout_toRightOf="@id/worldView"

android:text="hello"

/>

如图虚线即为基准线

Android4.2RelativeLayout新属性

<!--将当前控件的尾部对齐到兄弟控件的尾部-->

<TextView

android:id="@+id/Feng"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#FF00EE"

android:layout_below="@id/worldView"

android:layout_alignEnd="@id/worldView"

android:text="Feng"

/>

</RelativeLayout>

更多相关文章

  1. Android ListView控件基本用法
  2. Android的文本系列的控件
  3. android 控件属性大全
  4. 【Android】Android控件之Seekbar拖动条的使用
  5. android linearlayout 把控件view置底部(放在页面最下方)
  6. Android 之 自定义控件用法介绍
  7. Form表单组合控件

随机推荐

  1. Eclipse下开发Android的环境配置
  2. android BMI实例改进
  3. 解决ios软键盘输入框被遮挡问题
  4. Android 使用正则表达式验证邮箱格式是否
  5. android listview checkedTextView 的使
  6. android设计 实现窗体启动时,显示一个水平
  7. android 6.0/7.1 默认开启usb调试
  8. android 处理图片之--bitmap处理
  9. ADT 升级而对应SDK的tool和platform-tool
  10. Android(安卓)-- 传感器使用示例, 用方向