Is there a way to hide the system/navigation bar i

2019-01-10 09:58发布

I'd like to extend the discussion regarding hiding of the system/navigation bar at the bottom of the screen on Android Ice Cream Sandwich (4.0 and up) tablet devices.

There's already a thread ( Is there a way to hide the system bar in Android 3.0? It's an internal device and I'm managing navigation ) about hiding the bar on Honeycomb devices. My clients, however, will be using the newest Ice Cream Sandwich devices and are very keen on hiding the bar at the bottom the screen. Their application is not for regular consumer use and it's very important for them to take over the whole screen to provide their experience. How possible is it to hide this bar -- or at least, override the behaviour of all the buttons -- without rooting the devices or rewriting its firmware?

12条回答
一纸荒年 Trace。
2楼-- · 2019-01-10 10:54

on rooted devices, i use the following adb command

adb shell pm disable com.android.systemui

to hide navigation bar permanently. To show it again, run

adb shell pm enable com.android.systemui

so far it's working fine for me

查看更多
ゆ 、 Hurt°
3楼-- · 2019-01-10 10:55

Using the below code is one way of doing it to hide navigation

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

But the problem with the above is that it becomes visible as soon as user touches the screen.

In Android Kitkat there is a feature called as IMMERSIVE which hides the notification bar and the navigation. It does not show even if the user interacts with the screen. However the user can make it visible by swiping it from top of the screen to bottom. Below is the code to achieve it

//Initializew this in onCreate()
View mDecorView = getWindow().getDecorView();

//Then call this function
private void hideSystemUI() {
     mDecorView.setSystemUiVisibility(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
            | View.SYSTEM_UI_FLAG_LOW_PROFILE
            | View.SYSTEM_UI_FLAG_IMMERSIVE);
}

However in my case I never wanted the navigation and notification bar to be visible even if the user swipes from top of the screen to bottom. I gave it a try and I was able to achieve it partially. What I did was I implemented a CountDownTimerwhich would call hideSystemUI() every second or so. I know it is not the best way of doing it. But I did not get any other solution to do it.

If someone gets any then please let me know on how to permanently hide navigation and notification bar :) Hope this answer helps some one in future :)

Watch this video to better understand about this feature.

查看更多
smile是对你的礼貌
4楼-- · 2019-01-10 10:55

You can hide the navigation bar on Android 4.0 and higher using the SYSTEM_UI_FLAG_HIDE_NAVIGATION flag. This snippet hides both the navigation bar and the status bar:

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

See the following: Hiding the Navigation Bar

查看更多
戒情不戒烟
5楼-- · 2019-01-10 10:56

Check out SYSTEM_UI_FLAG_HIDE_NAVIGATION, this flag hides the navigation bar until the user interacts with the device. It was introduced in Android 4.0. You can enable this flag for example like this:

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

Note that the navigation won't disappear again automatically, you have to set it every time after the user interacted with the device.

Alternatively you can make the navigation less obtrusive by using SYSTEM_UI_FLAG_LOW_PROFILE, this changes the buttons into small dots (e.g. like the camera app).

查看更多
神经病院院长
6楼-- · 2019-01-10 10:57

You can not hide it unless you have rooted the device. But of course there is a workaround which might not fit with your requirement but several well known apps in the market at the moment using this strategy to achieve this disable menu bar feature for their apps.

  • Grant admin privilege.
  • Set password & lock the device using device admin profile api
  • Then load what ever the UIs on top of the native lock screen. (Of course this will show background lock screen whenever a transition happens between activities. But if logic is organized well, then it will be smooth & less noticed by the user)
  • When need to enable back, reset password to "" using resetPassword("", 0) of device policy manager object.
查看更多
何必那么认真
7楼-- · 2019-01-10 10:58

place this code in your application tag in manifest file to hide default tab bar

<Application
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" <!--
other parameters of application tag-->
>

and the then make a linear or relative layout and place it in your activity layout.

查看更多
登录 后发表回答