如何在Android 4中隐藏状态栏

发布于 2025-01-03 21:54:51 字数 131 浏览 1 评论 0 原文

如何在 Android 4 中隐藏 StatusBar:

StatusBar in Android 4

请帮助我。

How to hide StatusBar in Android 4:

StatusBar in Android 4

Help me, please.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

柠栀 2025-01-10 21:54:51

您问题中的图像中显示的栏称为系统栏。

在没有硬件按钮的设备上,如果发生用户输入,系统栏将始终显示。您可以使用标记 SYSTEM_UI_FLAG_HIDE_NAVIGATION 并请求以下窗口通过 FLAG_FULLSCREEN .com/reference/android/view/Window.html#setUiOptions%28int,%20int%29">窗口。只要用户不与屏幕交互,这就会隐藏系统栏并使您的视图全屏显示。如果用户触摸屏幕,系统栏将重新出现,以允许用户使用主页和返回软件键。

如果您有一个用户将与之交互的视图,但您希望他不要被系统栏分散注意力,您可以设置 SYSTEM_UI_FLAG_LOW_PROFILE 标志。这应该会使系统栏变暗并减少分散注意力。

The bar that is shown in the image in your question is called the system bar.

On devices with no hardware buttons the system bar will always be displayed if user input occurs. You can call setSystemUiVisibility with the flags SYSTEM_UI_FLAG_HIDE_NAVIGATION and request the following window feature FLAG_FULLSCREEN via the Window. This should hide the system bar and make your view fullscreen as long as the user does not interact with the screen. If the user touches the screen the system bar will reappear to allow the user to use the home and back software keys.

If you have a view that the user will interact with but you want him not to be distracted by the system bar you can set the SYSTEM_UI_FLAG_LOW_PROFILE flag. This should dim the system bar and make it less distracting.

寄居者 2025-01-10 21:54:51

我同意雅努斯的观点。在Android 4.0中你无法获得100%真正的全屏。

使用以下方法调暗通知栏(又名状态栏、系统栏)

getWindow().getDecorView().setSystemUiVisibility
  (View.SYSTEM_UI_FLAG_LOW_PROFILE); 

并使用它来隐藏它

getWindow().getDecorView().setSystemUiVisibility
  (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

并且,如果我猜对了,您正在尝试实现“信息亭模式”。您可以通过名为“surelock”的应用程序获得一些帮助。这会阻止所有“主页”和“后退”操作。

I agree with Janusz. You can not get 100% true full screen in Android 4.0.

Use the following to dim the notification bar (aka. status bar, system bar)

getWindow().getDecorView().setSystemUiVisibility
  (View.SYSTEM_UI_FLAG_LOW_PROFILE); 

And use this to hide it

getWindow().getDecorView().setSystemUiVisibility
  (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

And, if I guess right, you are trying to achieve a "kiosk mode". You can get a little help with an app named "surelock". This blocks all the "home" and "back" actions.

墨洒年华 2025-01-10 21:54:51

如果您希望获得流畅的体验,而无需中间的“急速”布局,这里是 API 级别 14 的解决方案。

final Window window = getWindow();
if (isFullScreen == true)
{
  window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
  // This flag will prevent the status bar disappearing animation from jerking the content view
  window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
  window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
else
{
  window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
  window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
  window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

If you wish a smooth experience without an intermediate "jerked" layout, here is the solution from API level 14.

final Window window = getWindow();
if (isFullScreen == true)
{
  window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
  // This flag will prevent the status bar disappearing animation from jerking the content view
  window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
  window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
else
{
  window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
  window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
  window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
凉城 2025-01-10 21:54:51

你可以隐藏它。只需在 OnCreate() 方法中使用以下 api

requestWindowFeature(Window.FEATURE_NO_TITLE);

you can hide it. just use following api in OnCreate() method

requestWindowFeature(Window.FEATURE_NO_TITLE);

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文