【发布时间】:2015-08-23 19:08:40
【问题描述】:
我正在尝试制作固定尺寸的动态按钮。我可以改变高度但无法改变宽度。按钮的宽度好像是 MATCH_PARENT(占据整个屏幕宽度。如果有两个按钮,每个按钮宽度是屏幕宽度的一半,只有一个按钮时,按钮宽度是屏幕宽度)。
TableLayout table = (TableLayout)findViewById(r.id.table);
TableRow tableRow = new TableRow(this);
table.addView(tableRow);
Button button = new Button(this);
button.setLayoutParams(new TableRow.LayoutParams(30,30));
tableRow.addView(button);
谁能指出我哪里出错了。
【问题讨论】:
标签: java android button dynamic layoutparams