Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/213.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Android应用程序代码中隐藏导航栏_Android_Navigation_Hide_Tablet_Adk - Fatal编程技术网

如何在Android应用程序代码中隐藏导航栏

如何在Android应用程序代码中隐藏导航栏,android,navigation,hide,tablet,adk,Android,Navigation,Hide,Tablet,Adk,我将此代码添加到我的应用程序中 View decorView = getWindow().getDecorView(); // Hide both the navigation bar and the status bar. int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(uiOpt

我将此代码添加到我的应用程序中

View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
但是代码强制我添加“SuppressLint NewApi到MainActivity”。还有一个关于“View.SYSTEM\u UI\u FLAG\u FULLSCREEN”的错误。代码说“CHANGE to…”,所以我不知道我必须做什么


请帮助我。非常感谢。

您使用的代码适用于API级别14或更高版本,如文档中所述

SuppressLint NewApi to MainActivity
之所以发生,可能是因为您的目标API级别(或minTarget)低于14

正如上面所说的,你不能隐藏导航栏

编辑:

设置您的
android:minSdkVersion=“14”

有一个限制:如果您使用的设备没有传统的硬件键(back、Home、Menu),则无法隐藏导航栏。

您使用的代码适用于API级别14或更高的版本,如文档中所述

SuppressLint NewApi to MainActivity
之所以发生,可能是因为您的目标API级别(或minTarget)低于14

正如上面所说的,你不能隐藏导航栏

编辑:

设置您的
android:minSdkVersion=“14”

有一个限制:如果您使用的设备没有传统的硬件键(后退、主页、菜单),则不能隐藏导航栏。

我就是这样做的-隐藏标题并使其全屏显示:

// requesting to turn the title OFF
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        // making it full screen
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
我的AndroidManifest应用程序中也有以下内容:

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

我应该注意这是minSDK版本的13和目标19(4.4 KitKat)

我就是这样做的-隐藏标题并使其全屏显示:

// requesting to turn the title OFF
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        // making it full screen
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
我的AndroidManifest应用程序中也有以下内容:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
我应该注意到这是一个minSDK版本的13和目标19(4.4 KitKat)

对于API级别19:

除了设置全屏标志外,我还必须添加以下内容来隐藏软键:

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);

您还可以按如下所述设置粘性浸入: 对于API 19级:

除了设置全屏标志外,我还必须添加以下内容来隐藏软键:

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);

您还可以按如下所述设置粘性浸入:

我是一个非常新手的开发人员,但我发现解决方案是更改主题,并将主题基于任何“…NoActionBar”主题。 我还不知道如何构建主题或修改样式,但我认为这可能是摆脱顶部动作栏的最有效方法。 但它不会让你进入全屏模式。我相信你必须按程序来做

<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="android:windowNoTitle">true</item>
</style>
<resources/>

真的

此外,如果您想了解更多关于主题的信息,这里似乎是一个很好的地方:

我是一个非常新手的开发人员,但我发现解决方案是更改主题,并将主题基于任何“…NoActionBar”主题。 我还不知道如何构建主题或修改样式,但我认为这可能是摆脱顶部动作栏的最有效方法。 但它不会让你进入全屏模式。我相信你必须按程序来做

<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="android:windowNoTitle">true</item>
</style>
<resources/>

真的

另外,如果您想了解更多关于主题的信息,这里似乎是一个很好的地方:

这里有在活动中隐藏导航栏的简单代码。它正在工作

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

下面是在活动中隐藏导航栏的简单代码。它正在工作

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

我找了这个培训,但没有帮助。你的目标Api是什么?我在使用4.0.4 Tablet我找了这个培训,但没有帮助。你的目标Api是什么?我在使用4.0.4 Tablet我是android的新手。我如何才能找到我的Api级别。我只知道我的设备版本是4.0.4打开你的
AndroidManifest.xml
an查看关于TargetVersion进入
标记。我正在更新我的答案,请检查:)好的,我做了,但我无法隐藏导航栏:/我是android新手。我如何才能找到我的Api级别。我只知道我的设备版本是4.0.4打开你的
AndroidManifest.xml
查看有关TargetVersion的行进入
标记。我正在更新我的答案,检查:)好的,我做了,但我无法隐藏导航栏:/