当前位置:   article > 正文

android解决BottomNavigationView超过三个组件文字不显示的问题(一行代码解决)_bottom navigation activity只有选中才显示文字

bottom navigation activity只有选中才显示文字

1. 问题描述

当我们在使用BottomNavigationView做底部bar时会多半遇到这样的情况:超过三个组件后文字不显示的问题,只有点击对应图标才显示,如图:
在这里插入图片描述

2. 问题解决

xml文件里面添加代码:

app:labelVisibilityMode="labeled"
  • 1

即可解决,详细代码如下,

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/nav_view"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="0dp"
        android:layout_marginEnd="0dp"
        android:background="@color/base_whiteF7"
        android:theme="@style/footButton"
        app:labelVisibilityMode="labeled"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:menu="@menu/bottom_nav_menu" />
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

效果如图:
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/984590
推荐阅读
相关标签
  

闽ICP备14008679号