[Android]设置Activity为全屏显示的两种方法
16lz
2022-01-09
2019独角兽企业重金招聘Python工程师标准>>>
1. 方法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. 方法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);
转载于:https://my.oschina.net/u/996206/blog/121786
更多相关文章
- Android(安卓)Activity生命周期
- TabWidget/TabHost的两种使用方法
- Android(安卓)Studio中的build.gradle文件解析
- Android中menu详解
- APK中实现关机
- Android事件分发机制全解析
- 查看基于Android(安卓)系统单个进程内存、CPU使用情况的几种方法
- 浅谈Java中Collections.sort对List排序的两种方法
- Python list sort方法的具体使用