[英]Unable to display all the buttons in TableLayout
I am generating buttons onto the screen programatically This is my code 我正在以编程方式在屏幕上生成按钮,这是我的代码
TableLayout MainLayout = new TableLayout(this);
MainLayout.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.MATCH_PARENT));
//MainLayout.setStretchAllColumns(true);
for ( int i =0 ; i < gridSize ; i++){
rowArr[i] = new TableRow(this);
for(int j = 0; j < gridSize ; j++){
Button button = new Button(this);
button.setText(Integer.toString(i)+","+Integer.toString(j));
button.setTextSize(150/gridSize);
button.setMaxHeight(450/gridSize);
button.setMaxWidth(600/gridSize);
rowArr[i].addView(button);
}
MainLayout.addView(rowArr[i]);
}
By the seeing the image you can an entire column of buttons are missing. 通过查看图像,您可能会丢失一整列按钮。
Only after setting my gridSize to 6 or more does this problem occur. 只有将我的gridSize设置为6或更大之后,才会出现此问题。
我可以在模拟器上看到第6行。我猜这是手机宽度引起的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.