我正在尝试制作这样的布局:
|---------------------------| |---------------------------|
| Title of text goes there | | Title of text goes there |
|---------------------------| |---------------------------|
| Image goes there, height | | Image goes there, height |
| can be different | | can be different, very |
|---------------------------| | very, very different |
| Long, very long text goes | |---------------------------|
| here, and here, and here | | Long, very long text goes |
| that should fill space | | here, and here, and here |
| lef after title and ima.. | | that should fill space ...|
|---------------------------| |---------------------------|
现在想象一下,我有 5 个这样的 LinearLayout 位于屏幕上,2 个上层和 3 个下层,全部均匀。问题是我的@Long,很长的文本不会椭圆化并同时填充可用空间。当我设置 android:maxLines 时,它可以工作,但我没有常量 maxLines,因为图像和标题高度会发生变化。
<!-- item -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dip"
android:layout_weight=".3">
<!-- item title -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:id="@+id/item_3_title"
android:textSize="22sp"
android:textStyle="bold"/>
<!-- item image -->
<RelativeLayout
android:id="@+id/item_3_image_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<ImageView
android:id="@+id/item_3_image"
android:layout_width="wrap_content"
android:layout_height="120dip"
android:scaleType="centerCrop"
android:padding="2dip" >
</ImageView>
<ProgressBar
android:id="@+id/item_3_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
</ProgressBar>
</RelativeLayout>
<!-- item text -->
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:id="@+id/item_3_text"
android:ellipsize="end"
android:textSize="18sp"/>
</LinearLayout>