我正在开发气泡聊天功能。我使用了一个带有两个布局的适配器,一个用于传入信息,另一个用于我的信息。适配器工作正常。我的问题在于传入布局不能很好地显示传入时间文本。当消息文本增长时,填充整个屏幕宽度,并隐藏消息时间文本。
第一个问题:如何解决这个问题?
这是传入消息的布局:
这是一个问题的图片:
编辑
当气泡里只有一个单词时,我需要橙色气泡与绿色气泡具有相同的行为,并在气泡充满文字时具有相同的行为(见绿色气泡)。
第一个问题:如何解决这个问题?
这是传入消息的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:animateLayoutChanges="true"
android:gravity="left">
<TextView
android:id="@+id/message_text_server"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5sp"
android:background="@drawable/speech_bubble_orange"
android:shadowColor="@color/textShadow"
android:shadowDx="1"
android:shadowDy="1"
android:text="Medium Text"
android:textColor="@color/textColor"
android:textSize="20sp" />
<RelativeLayout
android:id="@+id/message_server"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="left"
android:layout_gravity="left" >
<TextView
android:id="@+id/sended_server"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="9dp"
android:layout_marginTop="10sp"
android:text="Enviado"
android:textSize="10sp"
android:visibility="gone" />
<TextView
android:id="@+id/time_server"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="18dp"
android:layout_marginTop="23dp"
android:text="23:48"
android:textSize="10sp" />
</RelativeLayout>
</LinearLayout>
第二个问题
我的消息布局是相同的,但是元素的位置改变了而且能正常工作。为什么?这是一个问题的图片:
![Image](https://istack.dev59.com/blyur.webp)
![Image](https://istack.dev59.com/aVbzO.webp)