这么说吧,看别人的文章不如看开发者文档啊
隐藏导航栏 | Android 开发者 | Android Developers
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
hideSystemUI();
}
}
private void hideSystemUI() {
// Enables regular immersive mode.
// For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE.
// Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE
// Set the content to appear under the system bars so that the
// content doesn't resize when the system bars hide and show.
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE

本文介绍如何在Android应用中实现全屏显示并隐藏导航栏及状态栏的方法。通过覆盖`onWindowFocusChanged`方法并在其中调用自定义的`hideSystemUI`方法来达到效果。此外,文中还提到了在布局文件中避免使用`android:fitsSystemWindows=true`属性。
最低0.47元/天 解锁文章
680

被折叠的 条评论
为什么被折叠?



