我需要创建一个包含以下内容的 XML:
* 两个具有不同文本(1-3 行)的 TextView,一个 TextView 在另一个下方。
* 2 个 TextView 右侧的一个 ImageView,垂直居中,30x30 像素。
一个主要的限制是它不能在填充到 PopupWindow 时占据整个屏幕,这意味着我不能在很多地方使用属性 fill_parent。
我尝试了很多不同的布局,但是当文本很长时,ImageView 不断被 TextViews 推开。当文本为“半长”时,图像变得很小但仍然可见。我希望它始终为 30x30 像素,文本可以换行并使用另一行。
我试图指定宽度和 minWidth 的值。还为 ImageView 尝试了 layout_weight="1"。还尝试将 ImageView 包装成 LinearLayout 并给出 layout_weight="1" 参数。没有任何效果。
这是不起作用的示例:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:id="@+id/popupTitle" android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/popupContent"
android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</LinearLayout>
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="@drawable/img_30x30_px" />
</LinearLayout>