底部导航视图显示不正确

问题描述 投票:0回答:1

我的应用程序中有一些全屏活动,其底部具有底部导航视图。当应用程序具有导航栏时,看起来像这样:

enter image description here

当我删除导航栏时,底部导航视图似乎占据了它的位置(而不是停留在布局的底部):

enter image description here

这是设置android:layout_height="55dp"而不是"wrap_content"时的外观:

enter image description here

这是我删除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>

可能是什么问题?

android android-layout view bottomnavigationview
1个回答
0
投票

我运行并检查了您的代码。只需隐藏导航栏即可删除“ View.SYSTEM_UI_FLAG_LAYOUT_STABLE”标志。它将解决您的问题!我希望您能理解为什么删除此特定标志可以解决您的问题:)

© www.soinside.com 2019 - 2024. All rights reserved.