分享

android解决BottomNavigationView超过三个组件文字不显示的问题(一行代码解决)

 hncdman 2022-04-21



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" />


效果如图:

————————————————

版权声明:本文为CSDN博主「小白学知识」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/qq_41915623/article/details/124188753

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多