在android中隐藏按钮栏
我正在开发一个应用程序,需要在全屏模式在android中隐藏按钮栏,android,Android,我正在开发一个应用程序,需要在全屏模式 getWindow().getDecorView().setSystemUiVisibility(8); 我试图在清单中使用此代码 android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 但什么也没发生,按钮栏(如Home、Back和Recent Task App)仍然在那里。我需要把它们藏起来,这样才能全屏显示。请帮我做这个。多谢各位 尝试在setContentView(R.layout
getWindow().getDecorView().setSystemUiVisibility(8);
我试图在清单中使用此代码
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
但什么也没发生,按钮栏(如Home、Back和Recent Task App)仍然在那里。我需要把它们藏起来,这样才能全屏显示。请帮我做这个。多谢各位 尝试在
setContentView(R.layout.MainActivity)之前编写此代码代码>
这段代码对我很有用尝试在setContentView(R.layout.MainActivity)之前编写这段代码代码>
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);
这个代码对我有用
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中,您可以使用SYSTEM\u UI\u FLAG\u IMMERSIVE\u STICKY
FLAG:
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
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
见文件
看
从稍后的API 19中,您可以使用SYSTEM\u UI\u FLAG\u IMMERSIVE\u STICKY
FLAG:
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
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
请参阅文档@Bladebury有一个很好的答案,但您可能也希望了解这一点
您还描述了4.4kitkat
中名为沉浸式模式的新功能。
请注意,您需要API 19对其进行测试
查看@bladefury有一个很好的答案,但您可能也希望了解一下这个问题
您还描述了4.4kitkat
中名为沉浸式模式的新功能。
请注意,您需要API 19对其进行测试
查看经过大量研究,我终于找到了答案,并以全屏模式进行活动
getWindow().getDecorView().setSystemUiVisibility(8);
经过大量研究,我终于找到了答案,并以全屏模式进行活动
getWindow().getDecorView().setSystemUiVisibility(8);
我不确定询问者是否想要隐藏带时间的任务栏,等等。在我的代码中,带时间的任务栏实际上是隐藏的。但是按钮栏不是…是的。它消失了,但底部的按钮没有。我不确定询问者是否想要隐藏带时间的工具栏,等等。在我的代码中,带时间的任务栏实际上是隐藏的。但是按钮栏不是…是的。它消失了,但底部的按钮没有消失。@androidBoomer是的,通过这种方法,触摸屏幕上的任何地方都会使导航栏(和状态栏)重新出现并保持可见。用户交互导致清除标志。这是标准做法。用户交互将导致清除标志以启用导航。那么我该怎么做才能使其不清除标志?@androidBoomer您不能,但您可以在特定时间后重置标志time@androidBoomer是的,使用这种方法,触摸屏幕上的任何位置都会导致导航栏(和状态栏)重新出现并保持可见。用户交互导致清除标志。这是标准做法。用户交互将导致清除标志以启用导航。那么我该怎么做才能使其不清除标志?@androidBoomer您不能,但您可以在一段时间后重置标志