Совместите два TextViews, один слева, другой справа, на ListView, не растягивая фон

Итак, у меня есть дваTextViews за ряд вListView, Один должен быть слева, а другой справа. И то и другоеTextViews иметь в качестве фона скругленный прямоугольник, который должен просто обернуть текст внутри. Итак, я придумал это:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/text_right"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:background="@drawable/bubble_purple"
        android:gravity="center" >
    </TextView>

    <TextView
        android:id="@+id/text_left"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_toLeftOf="@id/text_right"
        android:background="@drawable/bubble_blue"
        android:gravity="center" >
    </TextView>
</RelativeLayout>

Это выглядит хорошо для длинных текстов, но не для коротких сообщений:

enter image description here

Я также попробовал LinearLayout так:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/text_left"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:background="@drawable/bubble_blue"
        android:gravity="center" >
    </TextView>

    <View
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_weight="1" />

    <TextView
        android:id="@+id/text_right"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:background="@drawable/bubble_purple"
        android:gravity="center">
    </TextView>
</LinearLayout>

Это работает для коротких сообщений, но не для длинных:

enter image description here

Можно ли как-то измерить общую ширинуTextViews и программно переключаться между этими раскладками, или я тут что-то не так делаю?

Ответы на вопрос(1)

Ваш ответ на вопрос