Ok I have a TableView, in which I'm inserting rows programatically. My Table looks following:
<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>
And I'm adding rows in such way:
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;
}
And the problem is now my table looks corrupted:
What I've tried is as suggested in this post to set on my tableLayout:
setColumnShrinkable(4,true);
However that doesn't work.
You help will be highly appreciated.