I need the following layout in my application:

As you can see, the text can be as wide as possible without pushing the screen away from other views that appear to the right, if necessary, ellipse. There will never be more than three color samples and at least 1, and all samples and x in the circle should always be visible. When the text is short, it should behave as shown in the last two lines (ferns) .
I tried to put text and images in LinearLayout , but when the text is too long, the images are not visible (or not fully visible). I suppose there is a way to indicate that images should always take up as much space as they need, while the TextView takes the rest or as much as it needs, but I cannot figure out how to do this. I don't know if RelativeLayout work better for this, or maybe TableLayout / TableRow or GridLayout , although nothing I read seems to affect this situation.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/plant_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:maxLines="1" android:singleLine="true" android:ellipsize="end" android:layout_marginRight="3dp"/> <LinearLayout android:id="@+id/color_0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="2dp" android:layout_marginRight="2dp"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/btn_remove_plant" android:visibility="invisible"/> </LinearLayout> <LinearLayout android:id="@+id/color_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="2dp" android:layout_marginRight="2dp" android:visibility="gone"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/btn_remove_plant" android:visibility="invisible"/> </LinearLayout> <LinearLayout android:id="@+id/color_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="2dp" android:layout_marginRight="2dp" android:visibility="gone"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/btn_remove_plant" android:visibility="invisible"/> </LinearLayout> <ImageView android:id="@+id/remove_plant" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/btn_remove_plant" android:layout_marginLeft="3dp"/> </LinearLayout>
source share