문제

I have a programmatically created created TableLayout with it's width set to match_parent. I am adding TableRows to it with 5 columns each. I have columns 1, 2, 4 & 5 all set to static widths. How do I set column 3 to fill the available space in the table so that the 5 columns total 100% width? (setting the TableRow width to match_parent does not do it)

도움이 되었습니까?

해결책

Set a weight for the column 3 layout, so that it will fill the remaining space in the TableRow

    LinearLayout linearLayout = new LinearLayout(this);
    TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT,1f);
    linearLayout.setLayoutParams(params);
    tableRow.addView(linearLayout);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top