我想做出一个适合所有智能手机的全屏模式。下面这段代码创建一个tablelayout布局,可以水平和垂直滚动。同时想把 edittext矩阵集放在布局的中间位置。怎么实现这个功能?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.seconda);
HorizontalScrollView HSC = new HorizontalScrollView(this);
ScrollView VSC = new ScrollView(this);
VSC.setBackgroundResource(R.drawable.lavagna_psd);
tableLayout = new TableLayout(this);
tableLayout.setGravity(Gravity.CENTER);
values = new EditText[3][3];
for (int i = 0; i < 3; i++) {
tableRow = new TableRow(this);
tableRow.setGravity(Gravity.CENTER);
for (int j = 0; j < 3 ; j++) {
values[i][j] = new EditText(this);
values[i][j].setHint("r: " + (i) + " " + "c: " + (j));
values[i][j].setPadding(10, 10, 10, 10);
tableRow.addView(values[i][j]);
}
tableLayout.addView(tableRow);
}
VSC.addView(tableLayout);
HSC.addView(VSC);
setContentView(HSC);
}