设置Activity为全屏显示的两种方法
16lz
2021-01-24
方法1:AndroidManifest.xml 里,Activity的 android:theme 指定为" @android :style/Theme.NoTitleBar.Fullscreen"
示例:
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme=" @android :style/Theme.NoTitleBar.Fullscreen">
android:name=".MainActivity">
方法2: 在onCreate()里指定No title
要加入:
/*set it to be no title*/
requestWindowFeature(Window.FEATURE_NO_TITLE);
/*set it to be full screen*/
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
示例:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*set it to be no title*/
requestWindowFeature(Window.FEATURE_NO_TITLE);
/*set it to be full screen*/
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
示例:
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme=" @android :style/Theme.NoTitleBar.Fullscreen">
android:name=".MainActivity">
方法2: 在onCreate()里指定No title
要加入:
/*set it to be no title*/
requestWindowFeature(Window.FEATURE_NO_TITLE);
/*set it to be full screen*/
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
示例:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*set it to be no title*/
requestWindowFeature(Window.FEATURE_NO_TITLE);
/*set it to be full screen*/
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
更多相关文章
- android studio 解决65536的方法(64K)
- 2013最新Android常用的工具类整理
- 【Android(安卓)应用开发】Activity 状态保存 OnSaveInstanceSta
- 短信发送--短信的发送流程(framework)
- Android(安卓)EditText 字符个数限制[转]
- Android路径中提取文件名
- Android(安卓)获取随机验证码功能示例
- Android中dp与px互转的方法
- android 自定义圆形进度条