這是目前我的列表視圖排佈置:的LinearLayout:如何正確包裝,沒有線較長的文本打破
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="5dp"
android:text="99.99.9999"
android:layout_weight="0.2"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0.6">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="This is a correct looking text"
android:id="@+id/txtComment"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.2">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:layout_marginRight="5dp"
android:text="-1234,56" />
</LinearLayout>
</LinearLayout>
問題是與ID txtComment
TextView的範圍內。對於包含常規換行符的短文本內容和文本內容,一切都很好看。
但是,只要沒有換行符的長文本,Android仍然會包裝文本,但也會改變周圍LinearLayout的權重,以便左右文本視圖被壓縮。
如何確保對於沒有換行符的長文本Android仍尊重元素的權重?
截圖顯示的問題:
這個工作很完美,謝謝 – devnull69