我遵循了制作Gestural Navigation的文档以将应用程序边缘扩展到边缘。但是我看不到导航栏变为透明。
build.gradle设置
compileSdkVersion 'android-Q'
minSdkVersion 21
targetSdkVersion 28
样式值
<!-- Testing Edge to Edge app content -->
<item name="android:navigationBarColor">@android:color/transparent</item>
<!-- Optional, but recommended for full edge-to-edge rendering -->
<item name="android:statusBarColor">@android:color/transparent</item>
我通过onCreate()
方法设置了UI可见性标记
// Adding UI Visibility flag for edge to edge app content
View view = findViewById(R.id.mainView);
// hide navigation
// view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
// layout stable
// view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
// view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
// view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_FULLSCREEN);
// having two flags hide navigation or layout fullscreen
// view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
// having two flags hide navigation or layout stable
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
答案 0 :(得分:1)
尝试一下:
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);