第一种情况......相对布局没有背景可绘制资源集...以下代码完全按预期工作,屏幕截图附加
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/parentLayout">
<Button android:text="Jill"
android:id="@+id/btnJill"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
<Button
android:id="@+id/btnJack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Jack"
android:layout_below="@id/btnJill"/>
</RelativeLayout>
第二种情况......相对布局有一个背景可绘制的资源集...现在只需添加一行就可以搞清楚结果,附上截图!
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/parentLayout"
android:background="@drawable/background">
<Button android:text="Jill"
android:id="@+id/btnJill"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
<Button
android:id="@+id/btnJack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Jack"
android:layout_below="@id/btnJill"/>
</RelativeLayout>
这必须是一个错误......如果没有人有解决方案。
答案 0 :(得分:0)
将android:layout_below="@id/btnJill"
更改为android:layout_below="@+id/btnJill"