几个背景词:申请将用于展览。它应该隐藏主页,后退,appswitcher按钮和通知栏以防止用户进行设置等。
设备:Samsung GT-N8000 Android 4.1.2
我试图通过SYSTEM_UI_FLAG_HIDE_NAVIGATION隐藏它们。
的AndroidManifest.xml
android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"
MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
setContentView(R.layout.activity_main);
}
Applicaiton在启动时隐藏它们。一切都好。但是当我在屏幕上触摸时,按钮和通知栏会出现在屏幕的底部。
更新:尝试通过onTouchEvent解决此问题
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
return true;
}
结果:触摸 - >导航正在打开,触摸>导航正在隐藏:( 如何完全(永久)隐藏按钮和通知栏?
答案 0 :(得分:0)
您需要使用沉浸式模式。请参阅此处的文档:Android Documentation
您需要添加此功能:
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
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 // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}