Android 底部导航栏未选中的文本不显示

21

我正在使用android.support.design.widget.BottomNavigationView。所有的东西都很好,除了未被选中的标题没有显示。

在此输入图片描述

<!-- layout -->
<android.support.design.widget.BottomNavigationView
    android:id="@+id/bnvBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="@android:color/background_light"
    android:theme="@style/BottomNavigationTheme"
    app:menu="@menu/bottom_navigation_main" />

<!-- theme -->
<style name="BottomNavigationTheme" parent="Theme.AppCompat.Light">
    <item name="colorPrimary">@color/orange</item>
</style>

缺少什么?


1
请查看此链接--> https://dev59.com/KVgR5IYBdhLWcg3wHqTB - Swati
2
尝试这个 - bottomNavigationView.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED) @Sean - Asteroid
1个回答

65

如果您正在使用Support Library 28,请尝试以下方法:

app:labelVisibilityMode="labeled"

完整代码

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/bnvBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@android:color/background_light"
        android:theme="@style/BottomNavigationTheme"
        app:menu="@menu/bottom_navigation_main" 
        app:labelVisibilityMode="labeled"
    />

谢谢你,伙计。你刚刚救了我的一天。我在不同的论坛上寻找答案。 - other Tall guy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接