我想做一個適合所有的智能手機的全屏幕視圖。使用這段代碼創建一個可以水平和垂直滾動的表格布局tablelayout。同時我也想查看集中在布局中編輯框edittext的模型。如何給所有的Activity設置全屏幕布局?謝謝。
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);
}
在應用程序上把主題設置為全屏。在androidmanifest的應用程序標記中添加以下代碼:android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"