Android Dimming the System Bars 隐藏虚拟按键
来源:互联网 发布:python ide vs 编辑:程序博客网 时间:2024/06/06 00:00
官方原文链接
Dim the Status and Navigation Bars
(隐藏状态栏和导航条)
You can dim the status and notification bars on Android 4.0 and higher using the SYSTEM_UI_FLAG_LOW_PROFILE flag, as follows:
// This example uses decor view, but you can use any visible view.View decorView = getActivity().getWindow().getDecorView();int uiOptions = View.SYSTEM_UI_FLAG_LOW_PROFILE;decorView.setSystemUiVisibility(uiOptions);
As soon as the user touches the status or navigation bar, the flag is cleared, causing the bars to be undimmed. Once the flag has been cleared, your app needs to reset it if you want to dim the bars again.
(如果点击了屏幕,这个Flag就被清除了,系统虚拟按钮将被显示,如果你还需要dim,请再次设置.)
Reveal the Status and Navigation Bars(显示状态栏和导航条)
If you want to programmatically clear flags set with setSystemUiVisibility(), you can do so as follows:
View decorView = getActivity().getWindow().getDecorView();// Calling setSystemUiVisibility() with a value of 0 clears// all flags.decorView.setSystemUiVisibility(0);
官方sample
代码片:
/** * Detects and toggles immersive mode (also known as "hidey bar" mode). */ public void toggleHideyBar() { // BEGIN_INCLUDE (get_current_ui_flags) // The UI options currently enabled are represented by a bitfield. // getSystemUiVisibility() gives us that bitfield. int uiOptions = getActivity().getWindow().getDecorView().getSystemUiVisibility(); int newUiOptions = uiOptions; // END_INCLUDE (get_current_ui_flags) // BEGIN_INCLUDE (toggle_ui_flags) boolean isImmersiveModeEnabled = ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions); if (isImmersiveModeEnabled) { Log.i(TAG, "Turning immersive mode mode off. "); } else { Log.i(TAG, "Turning immersive mode mode on."); } // Navigation bar hiding: Backwards compatible to ICS. if (Build.VERSION.SDK_INT >= 14) { newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; } // Status bar hiding: Backwards compatible to Jellybean if (Build.VERSION.SDK_INT >= 16) { newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN; } // Immersive mode: Backward compatible to KitKat. // Note that this flag doesn't do anything by itself, it only augments the behavior // of HIDE_NAVIGATION and FLAG_FULLSCREEN. For the purposes of this sample // all three flags are being toggled together. // Note that there are two immersive mode UI flags, one of which is referred to as "sticky". // Sticky immersive mode differs in that it makes the navigation and status bars // semi-transparent, and the UI flag does not get cleared when the user interacts with // the screen. if (Build.VERSION.SDK_INT >= 18) { newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; } getActivity().getWindow().getDecorView().setSystemUiVisibility(newUiOptions); //END_INCLUDE (set_ui_flags) }
在你的Activity种添加这样的一句代码:
<activity android:name=".MainActivity" android:label="@string/app_name" android:uiOptions="splitActionBarWhenNarrow"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
亲测可行,完毕.
1 0
- Android Dimming the System Bars 隐藏虚拟按键
- 管理系统UI之一:淡化System Bar(Dimming the System Bars)
- 管理系统UI之一:淡化System Bar(Dimming the System Bars)
- 管理系统UI之一:淡化System Bar(Dimming the System Bars)
- 管理系统UI之一:淡化System Bar(Dimming the System Bars)
- 管理系统UI之一:淡化System Bar(Dimming the System Bars)
- android 隐藏虚拟按键
- android隐藏底部虚拟按键
- 【Android】隐藏底部虚拟按键
- android全屏问题(隐藏虚拟按键)
- android 虚拟按键menu显示/隐藏问题
- 隐藏Android下的虚拟按键
- Android如何隐藏底部虚拟按键
- 手机游戏实现Android隐藏虚拟按键
- Android 隐藏手机底部虚拟按键
- android 隐藏状态栏 导航栏 虚拟按键
- Android 隐藏虚拟按键及状态栏
- 隐藏Android底部的虚拟按键
- mysql查询今天、昨天、7天、近30天、本月、上一月 数据
- 拒绝服务攻击-tfn2k
- Java泛型
- properties修改保留注解,重新加载properties到内存
- Qt5.3编译之configure选项
- Android Dimming the System Bars 隐藏虚拟按键
- LeetCode:House Robber
- 拓扑排序
- MYSQL用法(十七) MySQL中DATE_FORMAT()用法
- Open Inventor 简介
- 常用网站
- 微博收集
- 我的 App Crashed, 怎么办? – Part 1
- 详解java类的生命周期