【发布时间】:2014-06-30 12:22:21
【问题描述】:
我想显示文本(曲目标题)和文本右侧的视图。如下图所示。
视图(上面屏幕截图中的图像)应该始终可见。如果空间过多,则视图应显示在文本之后。如果没有足够的空间,文本应该被截断。
问题是:如果文本足够长,则视图不会显示或以较小的尺寸显示。
请不要推荐我使用带有drawableEnd 属性的文本视图,因为视图并不总是图像视图。
这是我使用的布局:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:id="@+id/trackTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:ellipsize="end"
android:text="@string/placeholderTrackTitle"
android:textSize="@dimen/track_name_height"
android:textColor="@color/queue_text_color"
android:layout_weight="0"/>
<ImageView
android:id="@+id/downloadedIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_downloaded"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/queue_horizontal_margin"
android:layout_marginRight="@dimen/queue_horizontal_margin"
android:layout_weight="1"
android:contentDescription="@string/downloaded_icon_description"/>
</LinearLayout>
【问题讨论】:
-
您希望显示文本和图像,但图像应始终在右侧,文本在左侧,如果文本太长则应截断,这就是你要找的吗?
-
@Goofy 差不多。我想要一个文本和一个视图(视图可能是也可能不是图像)。其他都是正确的。
-
请在下面查看我的答案,它可能对您有所帮助
-
你能告诉我在你的声明“视图并不总是图像视图”之类的文本之后必须显示什么类型的视图。
-
@Haresh 它可以是图像视图或圆形进度条。