RelativeLayout相对布局
所谓相对布局,即第二个控件的摆放,为第一个控件的相对位置
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FF0000"
android:text="第一个"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00ff00"
android:text="第二个"
android:layout_toRightOf="@id/textView1"//控件摆放在id为textView1控件的右边
/>
@id,为引用一个已经创建好的控件id
@+id,为创建一个新的控件id
android:layout_toLeftOf 摆放在左边
android:layout_below 摆放在下边
android:layout_above 摆放在上边
android:layout_alignRight="@id/textView1"对齐到右边
安卓入门.RelativeLayout相对布局1
相对布局详解
最新推荐文章于 2025-10-27 10:56:46 发布
本文详细介绍了RelativeLayout相对布局的概念及其使用方法。通过示例展示了如何利用属性如@+id创建新的控件ID,@id引用已存在的控件ID,以及android:layout_toRightOf等属性来指定控件之间的相对位置。
8695

被折叠的 条评论
为什么被折叠?



