当 Activity 以全屏模式运行时,如何允许 Android 系统状态栏在顶层出现,而不迫使 Activity 重新布局让出空间
2014-04-24 10:55
567 查看
当 Activity 以全屏模式运行时,如何允许 Android 系统状态栏在顶层出现,而不迫使 Activity
重新布局让出空间
private void hideStatusBar() {
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
}
private void showStatusBar() {
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
}
关键是,在做了该Activity的全屏设置的前提下,还要在onCreate()方法中加入如下语句:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
此方案我已经试过了,可行,且不会导致Activity重排。
此方案是我Google搜索出来的,网址如下:
Hacking Android: Show/hide status bar in fullscreen application
感谢他!
重新布局让出空间
private void hideStatusBar() {
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
}
private void showStatusBar() {
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
}
关键是,在做了该Activity的全屏设置的前提下,还要在onCreate()方法中加入如下语句:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
此方案我已经试过了,可行,且不会导致Activity重排。
此方案是我Google搜索出来的,网址如下:
Hacking Android: Show/hide status bar in fullscreen application
感谢他!
相关文章推荐
- 当 Activity 以全屏模式运行时,如何允许 Android 系统状态栏在顶层出现,而不迫使 Activity 重新布局让出空间?
- Android Activity 键盘弹出 布局重新分配空间
- Android设置全屏时出现unfortunately Activity has stopped,app不能运行
- Android启动模式以及如何通过adb指令查看app当前运行的activity
- android-如何获得当前正在运行的activity的相关信息
- Android屏幕适配全攻略(最权威的官方适配指导)Android屏幕适配出现的原因 在我们学习如何进行屏幕适配之前,我们需要先了解下为什么Android需要进行屏幕适配。 由于Android系统
- Android如何获取系统高度、标题栏和状态栏高度
- Android贴吧系统学习-----悬浮布局出现的bug--android.view.WindowManager$BadTokenException:
- 如何编译运行Android系统自带桌面Launcher2源码
- 如何设置Android系统中的BT2.1 device到SSP的DEBUG模式
- 请教一个问题,Android应用运行时在调用某个API(比如相机)时,系统如何判断这个应用是否具备相应的权限?
- Activity系列讲解---Activity运行时的屏幕方向,全屏,窗体模式的设置
- 解决 android如何设置全屏模式
- Activity嵌套多个Fragment实现不同全屏模式状态栏
- android-如何获得当前正在运行的activity的相关信息
- Android菜鸟笔记-Android平板实现全屏模式隐藏虚拟键和状态栏
- android系统如何在静音模式下关闭camera拍照声音
- android 使用多个Intent 进行activity跳转 而没有finish的情况,如何直接退出系统
- Android系统手机几种运行模式分析
- android监听系统状态栏的显示与隐藏(全屏与否)