Я пытаюсь создать макет чата, например WhatsApp. Я создал макет сообщения блока сообщения с сообщением и временем. Максимальная ширина этого блока должна быть 80% экрана. Если текст textView меньше ширины блока, тогда текст textView и time textView должны быть в строке. Если текст textView больше ширины блока, тогда он должен перейти в другую строку, и конец этой строки должен быть временным textView. Но я теряю timeView. Что я должен делать? Это мой макет:Как создать блок сообщений чата, например WhatsApp в android?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.80"
xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="right|top">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentTop="true"
android:layout_alignParentRight="true" android:layout_alignParentEnd="true"
android:layout_margin="10dp" android:background="#eee" android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:id="@+id/messageView" android:layout_marginRight="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10:52"
android:id="@+id/timeView" android:textColor="#999" android:textSize="10dp"/>
</LinearLayout>
</RelativeLayout>
У вас есть решение? Я устал искать решение для этого. –
Проверьте ссылку, которая вам должна помочь http://stackoverflow.com/a/30439423/3278589 – Subho