BottomNavigationView始终显示图标和文本标签 [英] BottomNavigationView display both icons and text labels at all times

查看:346
本文介绍了BottomNavigationView始终显示图标和文本标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用设计支持库版本25中的android.support.design.widget.BottomNavigationView

I am using android.support.design.widget.BottomNavigationView from design support library version 25

compile 'com.android.support:design:25.0.0'

<android.support.design.widget.BottomNavigationView
        android:id="@+id/bottomBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_gravity="center"
        app:itemBackground="@color/colorPrimary"
        app:menu="@menu/bottom_navigation_main"
        android:forceHasOverlappingRendering="true"/>

@ menu / bottom_navigation_main中只有三个操作时,它同时显示图标和文本标签

When there are only three actions in @menu/bottom_navigation_main, it displays both icons and text labels at all times.

当动作多于三个时,始终显示图标和文本标签的方式是什么。

What is the way to display both icons and text labels at all the time when there are more than three actions.

推荐答案

对于仍在寻找解决方案且不希望依赖第三方库或运行时反射的任何人,支持库28 / Jetpack中的BottomNavigationView本机支持始终具有文本标签。

For anyone still looking for a solution and doesn't want to rely on third party libraries or runtime reflection, BottomNavigationView in Support Library 28/Jetpack natively supports always having text label.

是您要寻找的方法。

This is the method you're looking for.

或者在XML中, app:labelVisibilityMode = labeled

这篇关于BottomNavigationView始终显示图标和文本标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆