逆水行舟用力撑,一篙松劲退千寻。这篇文章主要讲述Android 动态隐藏显示导航栏,状态栏相关的知识,希望能为你提供帮助。
Talk is cheap, show me the code.
--Linus
Torvalds
【Android 动态隐藏显示导航栏,状态栏】Okay, here:
一、导航栏:
[java]
view plain
copy
- private void hideNavigationBar() {
- View decorView = getWindow().getDecorView();
- int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_FULLSCREEN;
- decorView.setSystemUiVisibility(uiOptions);
- }
- private void showNavigationBar() {
- View decorView = getWindow().getDecorView();
- int uiOptions = View.SYSTEM_UI_FLAG_VISIBLE;
- decorView.setSystemUiVisibility(uiOptions);
- }
相关:
SYSTEM_UI_FLAG_VISIBLE——显示状态栏和导航栏
SYSTEM_UI_FLAG_LOW_PROFILE——此模式下,状态栏的图标可能是暗的
SYSTEM_UI_FLAG_HIDE_NAVIGATION——隐藏导航栏
SYSTEM_UI_FLAG_FULLSCREEN——全屏,隐藏状态栏和导航栏
SYSTEM_UI_FLAG_LAYOUT_STABLE
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN——全屏,隐藏导航栏,状态栏浮在布局上。
SYSTEM_UI_FLAG_IMMERSIVE——沉浸式:半透明的状态栏和导航栏
SYSTEM_UI_FLAG_IMMERSIVE_STICKY——粘性沉浸式
二、状态栏:
[java] view plain copy
- private void setStatusBarVisible(boolean show) {
- if (show) {
- int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
- uiFlags |= 0x00001000;
- getWindow().getDecorView().setSystemUiVisibility(uiFlags);
- } else {
- int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- | View.SYSTEM_UI_FLAG_FULLSCREEN;
- uiFlags |= 0x00001000;
- getWindow().getDecorView().setSystemUiVisibility(uiFlags);
- }
- }
三、导航栏和状态栏
[java] view plain copy
- private void setSystemUIVisible(boolean show) {
- if (show) {
- int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
- uiFlags |= 0x00001000;
- getWindow().getDecorView().setSystemUiVisibility(uiFlags);
- } else {
- int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_FULLSCREEN;
- uiFlags |= 0x00001000;
- getWindow().getDecorView().setSystemUiVisibility(uiFlags);
- }
- }
推荐阅读
- (转载)你真的理解Android AIDL中的in,out,inout么()
- Unity 打包发布Android新手教学 (小白都能看懂的教学 ) [转]
- Android零基础入门第49节(AdapterViewFlipper图片轮播)
- android studio 引用aar包出现文件冲突
- HDU 1452 Happy 2004 数论
- Android 优雅的让Fragment监听返回键
- Hibernate中的Entity类之间的继承关系之一MappedSuperclass
- Android : 下载内核源码 and 编译打包
- 如何设置电脑共享文件夹?本文教你设置办法