【问题标题】:BottomNavigationView does not follow layout heirarchyBottomNavigationView 不遵循布局层次结构
【发布时间】:2021-07-07 12:52:35
【问题描述】:

我有一个底部导航视图,我想通过在其顶部显示一个虚拟视图来隐藏它。在相对布局中,我将虚拟视图放在底部导航视图的顶部。但始终底​​部导航视图显示在顶部。为什么底部导航视图不遵循布局层次结构?

 <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/bottomNavigationView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="@color/white"
            android:theme="@style/BottomBar"
            android:visibility="visible"
            app:itemTextAppearanceActive="@style/BottomNavigationViewTextStyle"
            app:itemTextAppearanceInactive="@style/BottomNavigationViewTextStyle"
            app:labelVisibilityMode="labeled"
            app:menu="@menu/bottom_navigation_menu" />

        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentBottom="true"
            android:background="@color/black" />

    </RelativeLayout>

我希望视图显示在底部导航视图的顶部(以便底部导航视图不可见),但底部导航视图始终显示在顶部

【问题讨论】:

  • 发布截图。
  • 只显示底部导航视图,不确定为什么虚拟视图被隐藏。如果我删除虚拟视图并通过添加一个父布局将其放置在相对布局之外,则显示虚拟视图。
  • 确保您的假人与底部导航视图具有更高或相等的高度。
  • 谢谢@Pawel。根据以下链接material.io/components/bottom-navigation/…,底部导航视图的默认高度为 8dp。更改海拔应该可以解决问题。

标签: android androidx android-bottomnav android-bottomappbar


【解决方案1】:

基于以下链接https://material.io/components/bottom-navigation/android,底部导航视图的默认高度为 8dp。更改虚拟布局的高度将解决此问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-24
    • 2015-05-17
    相关资源
    最近更新 更多