好的我有一个TableView,我以编程方式插入行。我的表看起来如下:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TableLayout
android:id="@+id/tableLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:stretchColumns="0,1,2,3,4">
</TableLayout>
</LinearLayout>
</ScrollView>
我正在以这种方式添加行:
public void addRow () {
int rowHeight = 200;
final TableRow tbrow = new TableRow(this);
final TextView t1v = getTextView("10 ");
tbrow.addView(t1v);
t1v.requestLayout();
t1v.getLayoutParams().height = rowHeight;
final TextView t2v = getTextView("3");
tbrow.addView(t2v);
t2v.requestLayout();
t2v.getLayoutParams().height = rowHeight;
final TextView t3v = getTextView("5");
tbrow.addView(t3v);
t3v.requestLayout();
t3v.getLayoutParams().height = rowHeight;
final TextView t4v = getTextView("5");
tbrow.addView(t4v);
t4v.requestLayout();
t4v.getLayoutParams().height = rowHeight;
final TextView t5v = getTextView("from 1005\nto 1009");
tbrow.addView(t5v);
t5v.requestLayout();
t5v.getLayoutParams().height = rowHeight;
tl.addView(tbrow);
}
private TextView getTextView(String text)
{
TextView textView = new TextView(this);
textView.setText(text);
textView.setTextColor(Color.BLACK);
textView.setGravity(Gravity.CENTER);
textView.setBackground(gd3);
return textView;
}
问题是现在我的表看起来已损坏:
我尝试过的是this post中建议设置在我的tableLayout上:
setColumnShrinkable(4,true);
然而,这不起作用。
您的帮助将受到高度赞赏。