title: Make TextView as wide as possible without crowding out other views
body: <p>I want the following layout handling in my app:</p>
  
  <p><img src="https://i.stack.imgur.com/2WW2G.png" alt="enter image description here"></p>
  
  <p>As you can see, the text is allowed to be as wide as it can be without pushing off the screen the other views that appear to its right, ellipsizing as necessary. There will never be more than 3 color swatches, and no fewer than 1, and all swatches and the x in the circle must always be visible. <strong>When the text is short, it should behave as seen in the last 2 rows (the ferns)</strong>.</p>
  
  <p>I've tried to put the text and images in a <code>LinearLayout</code>, but when the text is too long the images are not visible (or not entirely visible). I assume there's some way to indicate that the images should always take up as much room as they need, with the <code>TextView</code> taking up the rest or as much as it needs, but I can't seem to figure out how. I don't know if a <code>RelativeLayout</code> would work better for this, or maybe a <code>TableLayout</code>/<code>TableRow</code> or <code>GridLayout</code>, though nothing I've read seems to cover this situation. </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="horizontal"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
  &lt;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"/&gt;
  
  &lt;LinearLayout
      android:id="@+id/color_0"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginLeft="2dp"
      android:layout_marginRight="2dp"&gt;
  
      &lt;ImageView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/btn_remove_plant"
          android:visibility="invisible"/&gt;
  &lt;/LinearLayout&gt;
  
  &lt;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"&gt;
  
      &lt;ImageView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/btn_remove_plant"
          android:visibility="invisible"/&gt;
  &lt;/LinearLayout&gt;
  
  &lt;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"&gt;
  
      &lt;ImageView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/btn_remove_plant"
          android:visibility="invisible"/&gt;
  &lt;/LinearLayout&gt;
  
  &lt;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"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>