1
아래와 같이 I 테이블 뷰 내부 버튼을 생성하는 응용 프로그램을 가지고 안드로이드 - tablerow 내부 프로그래밍 설정 버튼 폭
TableLayout table = (TableLayout) findViewById(R.id.tableLayout1);
for(int i = 0 ; i < Gatorade.getVariant().length ; i++){
int buttonsInRow = 0;
int numRows = table.getChildCount();
TableRow row = null;
if(numRows > 0){
row = (TableRow) table.getChildAt(numRows - 1);
buttonsInRow = row.getChildCount();
}
if(numRows == 0 || buttonsInRow == 3){
row = new TableRow(this);
table.addView(row);
buttonsInRow = 0;
}
if(buttonsInRow < 3){
Button b = new Button(this);
b.setText(Gatorade.getVariant()[i]);
//b.setWidth(pixels)
//b.setWidth()
row.addView(b, 100, 50);
}
}
프로그래밍
match_parent
에 버튼
wrap_content
너비 및 높이를 설정하는 방법이 ?
프로그래밍 방식으로 행의 단추를 배치하는 방법이 있습니까?
감사합니다.
감사합니다. 그러나 버튼 내용이 너무 길어서 세 번째 줄이 거의 보이지 않는 것 같았습니다. 테이블 행에 버튼을 고르게 분배하는 방법에 대한 아이디어가 있습니까? – Razgriz
가중치 사용 시도 – Nicholas
수정 된 코드 참조. –