我遇到了 TableLayout 行高的问题。
如果
android:stretchColumns="1"
结果是
你可以看到它被剪切的最后一行的文本
如果我不指定stretchColumns
结果是:
它现在显示的文本,但表格(黑色)变得非常大而没有内容。
这是代码:
<TableLayout
android:id="@+id/my_table"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"/>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_table_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="30dp"
android:weightSum="6" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:gravity="center" >
<ImageView
android:id="@+id/column_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3.9"
android:gravity="center_vertical|left" >
<TextView
android:id="@+id/column_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.7"
android:gravity="center_vertical|right" >
<TextView
android:id="@+id/column_three"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textSize="18sp" />
</LinearLayout>
</TableRow>
我正在填充行并以编程方式添加到表中。
为什么会这样?