title: Android. TextView doesn't wrap properly
body: <p>I have my text as "wrap_content" and another <code>View</code> behind it which extends to the limits of the <code>TextView</code>.</p>
  
  <p>Is there a way to make it wrap properly? In case of a text which needs an escape to a second line, it'll max out the width of the <code>TextView</code> in its parent and then escape the text, but it won't readjust the width to remove the white space which is left behind, as you can see below. </p>
  
  <p>i.e. what I would like to happen is the right side of the background come closer to the word <code>Write</code> and not leave that much amount of space there.</p>
  
  <p><a href="https://i.stack.imgur.com/d9t0N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d9t0N.png" alt="enter image description here"></a></p>
  
  <p>In case of single line text, everything looks fine.</p>
  
  <p><a href="https://i.stack.imgur.com/mp5mt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mp5mt.png" alt="enter image description here"></a></p>
  
  <p>Any ideas on how to wrap the text better?</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>//....
  &lt;RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_below="@id/list_item_bot_avatar"
      android:clipChildren="false"
      android:clipToPadding="false"&gt;
  
      &lt;!--ANIMATED CONTAINER--&gt;
      &lt;com.github.captain_miao.optroundcardview.OptRoundCardView
          android:id="@+id/list_item_bot_card"
          style="@style/BotTextMsgCardBot"&gt;
  
          &lt;com.airbnb.lottie.LottieAnimationView
              android:id="@+id/list_item_bot_typing_animation"
              style="@style/BotTextMsgTypingAnim" /&gt;
  
      &lt;/com.github.captain_miao.optroundcardview.OptRoundCardView&gt;
  
      &lt;!--TEXT--&gt;
      &lt;TextView
          android:id="@+id/list_item_bot_msg"
          style="@style/BotTextMsgTextBot" /&gt;
  
  &lt;/RelativeLayout&gt;
  //....
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;style name="BotTextMsgCardBot" parent="BotTextMsgCard"&gt;
      &lt;item name="optRoundCardBackgroundColor"&gt;@color/white&lt;/item&gt;
  &lt;/style&gt;
  
  &lt;style name="BotTextMsgCardUser" parent="BotTextMsgCard"&gt;
      &lt;item name="optRoundCardBackgroundColor"&gt;#28A8E0&lt;/item&gt;
  &lt;/style&gt;
  
  &lt;style name="BotTextMsgTypingAnim"&gt;
      &lt;item name="android:layout_width"&gt;wrap_content&lt;/item&gt;
      &lt;item name="android:layout_height"&gt;wrap_content&lt;/item&gt;
      &lt;item name="android:paddingTop"&gt;5dp&lt;/item&gt;
      &lt;item name="android:paddingBottom"&gt;5dp&lt;/item&gt;
      &lt;item name="android:paddingStart"&gt;5dp&lt;/item&gt;
      &lt;item name="android:paddingEnd"&gt;5dp&lt;/item&gt;
      &lt;item name="lottie_autoPlay"&gt;true&lt;/item&gt;
      &lt;item name="lottie_fileName"&gt;bot_typing.json&lt;/item&gt;
      &lt;item name="lottie_loop"&gt;true&lt;/item&gt;
  &lt;/style&gt;
  
  &lt;style name="BotTextMsgTextBot" parent="BotTextMsgText"&gt;
      &lt;item name="android:textColor"&gt;@color/black&lt;/item&gt;
  &lt;/style&gt;
  
  &lt;style name="BotTextMsgText"&gt;
      &lt;item name="android:layout_width"&gt;wrap_content&lt;/item&gt;
      &lt;item name="android:layout_height"&gt;wrap_content&lt;/item&gt;
      &lt;item name="android:paddingEnd"&gt;@dimen/bot_messages_horiz_spacing_x2&lt;/item&gt;
      &lt;item name="android:paddingStart"&gt;@dimen/bot_messages_horiz_spacing_x2&lt;/item&gt;
      &lt;item name="android:elevation"&gt;@dimen/bot_general_elevation&lt;/item&gt;
      &lt;item name="android:padding"&gt;10dp&lt;/item&gt;
      &lt;item name="android:textSize"&gt;14sp&lt;/item&gt;
      &lt;item name="key"&gt;ignore&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;dimen name="bot_general_elevation"&gt;3dp&lt;/dimen&gt;
  &lt;dimen name="bot_messages_horiz_spacing"&gt;10dp&lt;/dimen&gt;
  &lt;dimen name="bot_messages_horiz_spacing_x2"&gt;25dp&lt;/dimen&gt;
  </code></pre>