0
我有一個帶有TextView的TableView作爲單元格元素。目前我無法設置佈局文件,因此當文本寬度比單元格寬度寬時,TextView文本會多行顯示。它總是以表格單元的生長寬度超過屏幕寬度而結束。如何解決這個問題?將Android TableView和TextView作爲單元格 - 如何將TextView設置爲多行
我有一個帶有TextView的TableView作爲單元格元素。目前我無法設置佈局文件,因此當文本寬度比單元格寬度寬時,TextView文本會多行顯示。它總是以表格單元的生長寬度超過屏幕寬度而結束。如何解決這個問題?將Android TableView和TextView作爲單元格 - 如何將TextView設置爲多行
嘗試這樣:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<TableLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:stretchColumns="*"
android:id="@+id/tableLayout1">
<TableRow android:id="@+id/tableRow1" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:text="test1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="0" />
<TextView android:layout_weight="1"
android:text="test2 very long text that needs to be wrapped properly using layout_weight property and ignoring singleline since that is set by default..."
android:layout_width="fill_parent" android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
</LinearLayout>
設置一個固定的寬度到您的TextView,一切都應該工作...