我有以下布局.
<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>
Run Code Online (Sandbox Code Playgroud)
我希望ViewStub低于TextView,ImageView低于ViewStub.
ViewStub膨胀的元素按照我的预期显示.但没有ViewStub的元素将TextView与ImageView重叠.
我的布局出了什么问题?
更新:
我发现的唯一解决方案是为ViewStub和相关的TextView提供相同的android:id值.