Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在文本右侧显示视图_Android_Android Layout - Fatal编程技术网

Android 在文本右侧显示视图

Android 在文本右侧显示视图,android,android-layout,Android,Android Layout,我想显示文本(曲目标题)和文本右侧的视图。如下图所示 视图(上面屏幕截图上的图像)应始终可见。如果空间过大,视图应显示在文本的正后方。如果没有足够的空间,文本应该被截断 问题是:如果文本足够长,则视图不会显示或显示较小的尺寸 请不要建议我使用带有drawableEnd属性的文本视图,因为该视图并不总是图像视图 以下是我使用的布局: <LinearLayout android:layout_width="fill_parent" android:layout_height=

我想显示文本(曲目标题)和文本右侧的视图。如下图所示

视图(上面屏幕截图上的图像)应始终可见。如果空间过大,视图应显示在文本的正后方。如果没有足够的空间,文本应该被截断

问题是:如果文本足够长,则视图不会显示或显示较小的尺寸

请不要建议我使用带有
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>

使用文本视图上的属性,并在溢出时将文本省略


编辑:或者,或者,无论哪个更适合您的目的

好的,我使用的解决方案很少,而且效果很好

请勾选以下选项:

(一)


2)

您希望显示文本和图像,但图像应始终位于右侧,而文本应位于左侧,如果文本太长,则应将其截断,这就是您要查找的内容吗?@Goofy差不多。我想要一个文本和一个视图(视图可能是图像,也可能不是图像)。所有其他内容都是正确的。请检查我下面的答案,这可能会对您有所帮助。您可以知道在文本之后,您必须显示什么类型的视图,如您的声明“视图并不总是图像视图”.@Haresh它可以是图像视图或圆形进度条。看起来这两个链接都与视图定位问题无关。@Bobrovsky在你的问题
中的问题是:如果文本足够长,视图不会显示或显示得更小。
我已经回答了这个问题,恐怕你错了。您建议使用省略号功能,但我已经在使用它。hmmmm,在这种情况下,使用权重并固定视图大小,然后继续,这将解决您的问题。这不是我预期的解决方案,但在这里是最好的。