关于RelativeLayout的一点经验
16lz
2021-01-23
在使用RelativeLayout时,当用到layout above 和 layout bottom等属性时如下的xml会编译出错
<RelativeLayout android:id="@+id/RelativeLayout01"android:layout_width="wrap_content" android:layout_height="wrap_content"><View android:id="@+id/View02" android:layout_width="wrap_content"android:layout_height="wrap_content" android:layout_above="@id/View01"></View><View android:id="@+id/View01" android:layout_width="wrap_content"android:layout_height="wrap_content"></View></RelativeLayout>
解决的方法很简单,掉换一下View01和View02的位置
<RelativeLayout android:id="@+id/RelativeLayout01"android:layout_width="wrap_content" android:layout_height="wrap_content"><View android:id="@+id/View01" android:layout_width="wrap_content"android:layout_height="wrap_content"></View><View android:id="@+id/View02" android:layout_width="wrap_content"android:layout_height="wrap_content" android:layout_above="@id/View01"></View></RelativeLayout>
这个布局问题曾经困扰了我好长时间。。。实在想不到空间在xml布局文件中的位置竟然会影响编译结果
更多相关文章
- android LinearLayout布局子空间没有填充父控件的问题
- RelativeLayout里常用的位置属性
- Android界面布局详解
- android_relative布局参数学习
- Android开发之——布局实例
- 【Android 界面效果14】RelativeLayout里常用的位置属性