I want to display text (track title) and a view to right of the text. Like on the image below.
The view (image on the screenshot above) should always be visible. The view should be displayed right after the text if there is more room than necessary. The text should be truncated if there is not enough room.
The issue is: if the text is long enough the view is not displayed or displayed in smaller size.
Please don't recommend me to use text view with a drawableEnd
attribute because the view not always will be an image view.
Here is the layout I use:
<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>