RelativeLayout 知识点

来源:互联网 发布:英语口语8000句软件 编辑:程序博客网 时间:2024/06/09 17:31

1.RelativeLayout层叠

a.布局文件如下

   <RelativeLayout            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_alignBottom="@+id/vp_content"            android:layout_alignParentRight="true" ><!-- 这里放了一个LinearLayout 和一个ImageView,他的先后顺序,决定了层次的上下,若是这样布局,则LinearLayout在上层。 -->            <LinearLayout                android:id="@+id/ll_point_list"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:orientation="horizontal" >            </LinearLayout>            <ImageView                android:id="@+id/red_point"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:src="@drawable/small_point_red" />        </RelativeLayout>

b.结论

所以在RelativeLayout布局中加控件时要考虑先后顺序,放在前面的在下层。

摘:http://www.th7.cn/Program/Android/201404/188860.shtml

1.RelativeLayout布局中的元素如果要实现元素叠加必须设置RelativeLayout.ALIGN_PARENT_TOP 和 RelativeLayout.ALIGN_PARENT_LEFT 这样元素才会进行叠加,否则元素就会按照加入的顺序无叠加放置。

2.RelativeLayout布局中的叠加元素的次序只决定于声明的先后(无论是使用xml布局文件还是使用纯代码布局),也就是说一旦开始决定了他们的叠放次序,就无法更改了,即使删除之后再次进行添加也不行。

0 0
原创粉丝点击