设置android全屏的两种方式
16lz
2022-03-16
一、在代码中设置:
无title和全屏段代码必须在setContentView(R.layout.main) 之前,不然会报错。 二、在配置文件里修改(android:theme=”@android:style/Theme.NoTitleBar.Fullscreen”)
用一的情况在应用运行后,会看到短暂的状态栏,然后才全屏,而第二种方法是不会有这种情况的。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | package com.hhh.changeimage; import android.app.Activity; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; public class ChangeImage extends Activity { public void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); //无title requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams. FLAG_FULLSCREEN); setContentView(R.layout.main); } |
1 2 3 4 5 6 7 8 | < activity android:name = ".ChangeImage" android:theme = "@android:style/Theme.NoTitleBar.Fullscreen" android:label = "@string/app_name" > < intent-filter > < action android:name = "android.intent.action.MAIN" /> < category android:name = "android.intent.category.LAUNCHER" /> </ intent-filter > </ activity > |
更多相关文章
- Android(安卓)关于显示键盘,布局错乱网上顶的问题
- Android(安卓)代码片段---从相册或相机获取图片保存并处理
- Eclipse 开发 Android, Hello FormStuff(学习9)
- Android(安卓)监听WiFi的开关状态实现代码
- [Android]android.util.AndroidRuntimeException: requestFeatur
- Android(安卓)TTS的简单应用
- Android(安卓)ANR 分析
- android如何用代码实现界面ui
- android 如何获取当前运行的activity