私は次のレイアウトを持っています。
<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
値を与えることです。