我想创建一个按钮,能够在我的平板电脑上隐藏或显示状态栏。我已经放置了在onCreate中。
//编辑
我看了这个提示:http://android.serverbox.ch/?p=306 并像这样更改了我的代码:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
并且在按钮中显示:
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
隐藏:
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
任何提示/技巧吗?//编辑
我看了这个提示:http://android.serverbox.ch/?p=306 并像这样更改了我的代码:
private void hideStatusBar() throws IOException, InterruptedException {
Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 79 s16 com.android.systemui"});
proc.waitFor();
}
private void showStatusBar() throws IOException, InterruptedException {
Process proc = Runtime.getRuntime().exec(new String[]{"am","startservice","-n","com.android.systemui/.SystemUIService"});
proc.waitFor();
}
如果我点击按钮并调用方法,我可以看到应用程序正在等待一些秒钟,所以我知道发生了一些事情。 我还查看了 LockCat 并看到有一些进展。
显示: http://pastebin.com/CidTRSTi 隐藏: http://pastebin.com/iPS6Kgbp
Theme.Dark.NoTitleBar.Fullscreen
的主题。但是,有一个名为Theme.NoTitleBar.Fullscreen
的主题。然而,在Android 3.0+设备上缺少屏幕外HOME和BACK按钮的情况下,您无法摆脱系统栏。 - CommonsWare