【发布时间】:2012-10-24 08:34:00
【问题描述】:
我有以下布局。
<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 值。
【问题讨论】:
-
为什么不把它放在
LinearLayout中呢?并把它放在中间
标签: android android-relativelayout inflate viewstub