在xml中,标签从上到下的排列顺序,决定了在手机屏幕上的,位于上下层的顺序
如:<RelativeLayout xmlns: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"
<!--灰色透明的LinearLayout-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#55CDCDC1">
</LinearLayout>
<Button
android:layout_width="50dp"
android:layout_height="50dp" />
</RelativeLayout>
如果这样写,按钮就在灰色透明的LinearLayout上面,
如果交换button和LinearLayout的位置,按钮就在灰色透明的LinearLayout下面
本文解析了在XML布局文件中,元素标签的排列顺序如何决定视图在屏幕上的层级关系。通过一个具体的RelativeLayout示例,说明了LinearLayout和Button位置变化对显示效果的影响。
1948

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



