Android ICS中有没有隐藏系统/导航栏的方法?

21

我想进一步讨论如何在安卓冰淇淋三明治(4.0及以上)平板设备上隐藏屏幕底部的系统/导航栏。

已经有一个主题 (Is there a way to hide the system bar in Android 3.0? It's an internal device and I'm managing navigation) 关于如何在Honeycomb设备上隐藏该栏。然而,我的客户将使用最新的Ice Cream Sandwich设备,并非常渴望隐藏屏幕底部的该栏。他们的应用程序并不是为普通消费者使用,非常重要的是他们需要占据整个屏幕以提供完整的用户体验。那么在不进行root或重写固件的情况下,是否有可能隐藏这个栏 - 或者至少覆盖所有按钮的行为呢?


1
可能是重复的问题有没有办法在Android 3.0中隐藏系统栏?这是一个内部设备,我正在管理导航 - Honeycomb的答案对ICS仍然有效。 - WarrenFaith
1
看起来Honeycomb和ICS在系统栏方面存在重大差异。请参考http://android.serverbox.ch/?p=306,尤其是2011年12月29日17:20的回复。 - user316117
他指的是4.0及以上版本。自从4.4以来,谷歌的VR努力已经引发了一种新的模式。 请参见下面关于沉浸式模式的评论。 https://developer.android.com/training/system-ui/immersive.html - Dominic Cerisano
12个回答

0

您可以使用SYSTEM_UI_FLAG_HIDE_NAVIGATION标志在Android 4.0及更高版本上隐藏导航栏。此代码段将同时隐藏导航栏和状态栏:

View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions

请看下面:隐藏导航栏

-2
如果您的设备已经root,这段代码将帮助您在ICS上隐藏系统栏(我在三星Galaxy Tab 2上测试过,效果非常好):
ArrayList<String> list = new ArrayList<String>();
Map<String, String> env = System.getenv();
for (String envName : env.keySet()) {
    list.add(envName + "=" + env.get(envName));
}

// Array containing the environment to start the new process in
String[] envp = (String[]) list.toArray(new String[0]);

String hidingCommand = "while [ true ]\n" + "do\n" + "killall com.android.systemui\n" + "done\n";
Runtime.getRuntime().exec(new String[] { "su", "-c", command }, envp);

myContext.sendBroadcast(new Intent("com.mycompany.myapp.ACTION_BARHIDDEN"));

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接