我的应用程序中有一些全屏活动,其底部具有底部导航视图。当应用程序具有导航栏时,看起来像这样:
当我移除导航栏时,底部导航视图似乎已填满它的位置(而不是停留在布局的底部):
这是我设置android:layout_height="55dp"
而不是"wrap_content"
时的样子:
这是我删除navigation bar
的方式:
@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);
}
这是我的活动的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>
可能是什么问题?
答案 0 :(得分:0)
我跑来检查了你的代码。只需隐藏导航栏即可删除“ View.SYSTEM_UI_FLAG_LAYOUT_STABLE”标志。它将解决您的问题!我希望您能理解为什么删除此特定标志可以解决您的问题:)