我的应用程序中有一些全屏 Activity ,底部有底部导航 View 。当应用程序有导航栏时,它看起来很好,如下所示:
当我删除导航栏时,底部导航 View 似乎填充了它的位置(而不是粘在布局的底部):
这就是我设置 android:layout_height="55dp"
而不是 "wrap_content"
时的样子:
这就是我删除导航栏
的方法:
@Override
public void onResume(){
super.onResume();
View aView = getWindow().getDecorView();
aView.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
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
这是我的 Activity XML 的代码:
<FrameLayout
android:id="@+id/main_activity_fragment_container"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
app:layout_constraintBottom_toTopOf="@+id/navigation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</FrameLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:backgroundTint="@color/colorPrimary"
app:itemIconTint="@color/bnv_colors_main_menu"
app:itemTextColor="@color/bnv_colors_main_menu"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/navigation_main_menu"
app:labelVisibilityMode="labeled"
>
</com.google.android.material.bottomnavigation.BottomNavigationView>
可能是什么问题?
最佳答案
我运行并检查了你的代码。只需在隐藏导航栏时删除“View.SYSTEM_UI_FLAG_LAYOUT_STABLE”标志即可。它会解决你的问题!我希望您能理解为什么删除这个特定标志可以解决您的问题:)
关于android - 底部导航 View 显示不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60134630/