Android之相对布局
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>
更多相关文章
- Android ListView控件基本用法
- Android的文本系列的控件
- android 控件属性大全
- 【Android】Android控件之Seekbar拖动条的使用
- android linearlayout 把控件view置底部(放在页面最下方)
- Android 之 自定义控件用法介绍
- Form表单组合控件