我想做一個android應用程序的chatview,但我有一個擠壓消息時間的聊天泡泡的問題,直到它完全崩潰它,然後它包裹到下一行。 這是XML:一個TextView擠出另一個時,它擴大而不是包裝
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left|center"
android:orientation="horizontal"
android:weightSum="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:gravity="left|center"
android:orientation="horizontal">
<TextView
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/chat_levi"
android:padding="10dp"
android:text="Insert text here"
android:textColor="@color/blueGray50"
android:textSize="16sp" />
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="bottom|left"
android:text="18:30"
android:textSize="14sp" />
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0.2" />
</LinearLayout>
我還爲聊天室中的其他用戶設置了另一個佈局,對他而言,我剛剛將所有重力式左變更爲權限,並將某些元素的位置如上圖所示(它非常類似的代碼,所以我排除了它,但如果有人問它,我會加上它)。對於那個,我得到了預期的效果。
是否有某種修復來獲得的第一個表現方式與鏡像同一個?
您可以添加proprety「機器人:MAXLINES:「1 「」。這將允許您的TextView只有一行 –
這只是使TextView的時間不會將其文本壓縮到下一行,然後它被擠出。 –
爲什麼你不給時間一個固定的寬度? – Journey