3

我在 xml 中有一个表格布局。我还在代码中添加了一些行。如何在代码中设置某些视图的 column_layout?

在xml中我有:

android:layout_column="3"

如何在代码中实现相同的功能(例如对于 TextView)?

4

2 回答 2

7
        TextView tv = new TextView(this); 
        tv.setLayoutParams(new TableRow.LayoutParams(3));
于 2011-05-27T18:56:16.923 回答
0

我不完全确定我理解这些问题,但是 MyTracks for Android 使用表格布局提供了一些不错的示例代码。可以在这里找到。

感谢您的评论。我想这就是你要找的:< TableLayout xmlns: android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="3">

<TableRow>
    <TextView
        android:layout_column="1"
        android:text="Open..."
        android:padding="3dip" />
    <TextView
        android:text="Ctrl-O"
        android:gravity="right"
        android:padding="3dip" />
    <TextView
        android:text="String"
        android:gravity="right"
        android:padding="3dip" />
</TableRow> ...`
于 2011-05-21T13:32:11.757 回答