问题描述
- 给所有的Activity设置全屏幕布局
-
我想做一个适合所有的智能手机的全屏幕视图。使用这段代码创建一个可以水平和垂直滚动的表格布局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"
解决方案二:
在配置文件中设置android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
或者在oncreate()中加入
getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,
WindowManager.LayoutParams. FLAG_FULLSCREEN);
时间: 2024-09-08 09:41:58