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 相对定位布局方向详解
  2. Android(安卓)ListView控件基本用法
  3. [Android]【安卓】开发小结
  4. android 布局详解
  5. Android中UI设计的一些技巧!!!
  6. Android中的五大布局
  7. Android的文本系列的控件
  8. android的图片添加、滚动条、单选框、多选框、跳转界面
  9. android 控件属性大全

随机推荐

  1. android studio怎么导入appcompat-v7
  2. Android使用SQLite数据库(1)
  3. 恢复工厂设置流程
  4. Android(安卓)SDK Manager安装过程
  5. android开发出现No Launcher activity fo
  6. 清单文件Manifest中的android:name
  7. android中判断网络是否连接
  8. Android之录制视频文件
  9. Android开发错误信息与解决方案汇总
  10. Android(安卓)for x86