我有以下布局。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/list_item_bottom">
<TextView android:id="@+id/list_item_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ViewStub android:id="@+id/stub_for_alt_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/list_item_name"
android:layout="@layout/text_view_alt_name"/>
<ImageView android:id="@+id/list_item_dopinfo1_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/stub_for_alt_name"
android:src="@drawable/ic_released"/>
</RelativeLayout>
我希望 ViewStub 低于 TextView 和 ImageView 低于 ViewStub。
ViewStub 膨胀的元素按我的预期显示。但是没有 ViewStub 的元素的 TextView 与 ImageView 重叠。
我的布局有什么问题?
更新:
我发现的唯一解决方案是给 ViewStub 和相关的 TextView 相同的android:id
值。