0

I have my text as "wrap_content" and another View behind it which extends to the limits of the TextView.

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 TextView 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.

i.e. what I would like to happen is the right side of the background come closer to the word Write and not leave that much amount of space there.

enter image description here

In case of single line text, everything looks fine.

enter image description here

Any ideas on how to wrap the text better?

EDIT

//....
<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">

    <!--ANIMATED CONTAINER-->
    <com.github.captain_miao.optroundcardview.OptRoundCardView
        android:id="@+id/list_item_bot_card"
        style="@style/BotTextMsgCardBot">

        <com.airbnb.lottie.LottieAnimationView
            android:id="@+id/list_item_bot_typing_animation"
            style="@style/BotTextMsgTypingAnim" />

    </com.github.captain_miao.optroundcardview.OptRoundCardView>

    <!--TEXT-->
    <TextView
        android:id="@+id/list_item_bot_msg"
        style="@style/BotTextMsgTextBot" />

</RelativeLayout>
//....

and

<style name="BotTextMsgCardBot" parent="BotTextMsgCard">
    <item name="optRoundCardBackgroundColor">@color/white</item>
</style>

<style name="BotTextMsgCardUser" parent="BotTextMsgCard">
    <item name="optRoundCardBackgroundColor">#28A8E0</item>
</style>

<style name="BotTextMsgTypingAnim">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:paddingTop">5dp</item>
    <item name="android:paddingBottom">5dp</item>
    <item name="android:paddingStart">5dp</item>
    <item name="android:paddingEnd">5dp</item>
    <item name="lottie_autoPlay">true</item>
    <item name="lottie_fileName">bot_typing.json</item>
    <item name="lottie_loop">true</item>
</style>

<style name="BotTextMsgTextBot" parent="BotTextMsgText">
    <item name="android:textColor">@color/black</item>
</style>

<style name="BotTextMsgText">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:paddingEnd">@dimen/bot_messages_horiz_spacing_x2</item>
    <item name="android:paddingStart">@dimen/bot_messages_horiz_spacing_x2</item>
    <item name="android:elevation">@dimen/bot_general_elevation</item>
    <item name="android:padding">10dp</item>
    <item name="android:textSize">14sp</item>
    <item name="key">ignore</item>
</style>

and

<dimen name="bot_general_elevation">3dp</dimen>
<dimen name="bot_messages_horiz_spacing">10dp</dimen>
<dimen name="bot_messages_horiz_spacing_x2">25dp</dimen>
AndreiBogdan
  • 10,858
  • 13
  • 58
  • 106

0 Answers0