Android tablet navigation bar won't hide

冷暖自知 提交于 2019-11-27 06:31:17

问题


I'm trying to hide the navigation bar, using methods I've found described on the internet.

I have a simple layout which shows a WebView:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:id="@+id/layout" >

    <WebView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

</RelativeLayout>

The code that I'm using at app startup is:

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
    web.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
    layout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

But this doesn't hide the navigation bar.

I've added...

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

... to my activity too.

How can I achieve this?


回答1:


You cannot permanently hide the system bar on a tablet.

SYSTEM_UI_FLAG_HIDE_NAVIGATION on Android 4.1 and higher will hide the system bar, but it will reappear as soon as the user does anything.




回答2:


you can hide the navigationbar,try this

public void FullScreencall() {
    if(Build.VERSION.SDK_INT < 19) //19 or above api
        View v = this.getWindow().getDecorView();
        v.setSystemUiVisibility(View.GONE);
    } else {
            //for lower api versions.
        View decorView = getWindow().getDecorView(); 
        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        decorView.setSystemUiVisibility(uiOptions);
    }
}



回答3:


You can not hide the navigation bar within the given framework. However, there is a work around if rooting the device is an option for you:

  1. Root device

  2. Install and run Busybox

  3. Install HideBar

In HideBar there is an option to run in 'Kiosk' mode, in which there is no way to re-display the navigation bar. Needless to say, you really need to be careful with this.




来源:https://stackoverflow.com/questions/12804642/android-tablet-navigation-bar-wont-hide

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!