Android平板电脑导航栏不会隐藏

时间:2023-01-17 14:25:46

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:

我有一个简单的布局,显示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:

我在app启动时使用的代码是:

    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?

我怎样才能做到这一点?

3 个解决方案

#1


4  

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.

Android 4.1及更高版本上的SYSTEM_UI_FLAG_HIDE_NAVIGATION将隐藏系统栏,但只要用户执行任何操作,它就会重新出现。

#2


5  

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


0  

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

    安装并运行Busybox

  3. Install HideBar

    安装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.

在HideBar中,有一个选项可以在“Kiosk”模式下运行,在该模式下无法重新显示导航栏。不用说,你真的需要小心这一点。


#1


4  

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.

Android 4.1及更高版本上的SYSTEM_UI_FLAG_HIDE_NAVIGATION将隐藏系统栏,但只要用户执行任何操作,它就会重新出现。

#2


5  

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


0  

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

    安装并运行Busybox

  3. Install HideBar

    安装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.

在HideBar中,有一个选项可以在“Kiosk”模式下运行,在该模式下无法重新显示导航栏。不用说,你真的需要小心这一点。