的Android layout_below我遇到了一个奇怪的问题,下面是我的布局:中的RelativeLayout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:src="@color/colorAccent"
android:layout_width="match_parent"
android:layout_height="200dp"/>
<ImageView
android:id="@+id/image"
android:src="@mipmap/ic_launcher"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="text"
android:layout_below="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
TextView
不低于ImageView
如预期,这是下面的ImageView
原来的位置。
如果我将layout_height
的RelativeLayout
设置为200dp
或match_parent
,它工作正常。
我该如何解决这个问题?
那么这是一个相对的布局。您需要指定每个元素相对于另一个元素的位置。要对齐行或列中的所有元素,请使用LinearLayout – Imdad
为什么要添加第一个图像视图?如果要更改布局的背景色,可以使用另一种方法。 –
使用match_parent代替wrap_content到根布局。 –