【发布时间】:2011-06-10 03:16:04
【问题描述】:
作为更大 UI 的一部分,我有一个 RelativeLayout,其中包含三个我希望具有相同宽度的视图。三个视图像这样“堆叠”在彼此之上
ImageViewTextViewImageView
我尝试了各种方法,例如将Views' android:layout_width 设置为“wrap_content”,将android:layout_width 设置为“0px”,将android:layout_weight 设置为“1”,如this answer 所建议的那样,以及将Views 放在LinearLayout 中没有成功。
如何让这三个视图的宽度相同?
布局xml的相关部分:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="1">
<ImageView
android:layout_above="@string/window_text"
android:layout_below="@string/eighteen_id"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingTop="5dp"
android:layout_alignParentRight="true"
android:paddingBottom="5dp"
android:src="@drawable/line1"
android:id="@string/line_1_id"/>
<TextView
android:layout_above="@string/line_2_id"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="right"
android:layout_centerVertical="true"
android:textColor="#000000"
android:id="@string/window_text"/>
<ImageView
android:layout_above="@string/top_row_id"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:src="@drawable/line1"
android:id="@string/line_2_id"/>
</RelativeLayout>
【问题讨论】:
-
您显示的是RelativeLayout,而不是LinearLayout?
-
我在这个
RelativeLayout下还有其他几个Views,它们使用相对定位。
标签: android layout view size width