在使用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布局文件中的位置竟然会影响编译结果