How to disable BottomNavigationView shift mode?

2019-01-01 05:11发布

BottomNavigationView doesn't show menu's title that are inactive.

How to show titles of all menu elements in bottomNavigationBar? The problem is that in my case shown only title of element that is clicked.

enter image description here

16条回答
孤独寂梦人
2楼-- · 2019-01-01 05:21

For updated answer using the default. Update to latest design library

implementation "com.android.support:design:28.0.0"

and put to your BottomNavigationView xml attributes

app:itemHorizontalTranslationEnabled="false"

you can put it also as programmatically

bottomNavigationView.setItemHorizontalTranslationEnabled(false);

You can find source here BottomNavigationView

Hope this helps you.

查看更多
孤独总比滥情好
3楼-- · 2019-01-01 05:25

Works for me

bottomNavigationView.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED);

or

<android.support.design.widget.BottomNavigationView
    app:labelVisibilityMode="labeled" />
查看更多
几人难应
4楼-- · 2019-01-01 05:26

To disable the text animation and decrease font size use this in your dimens.xml file:

<dimen name="design_bottom_navigation_text_size">10sp</dimen> 
<dimen name="design_bottom_navigation_active_text_size">10sp</dimen>
查看更多
倾城一夜雪
5楼-- · 2019-01-01 05:26

As others have pointed out, since support library 28.0.0-alpha1 it is possible:

<android.support.design.widget.BottomNavigationView
app:labelVisibilityMode="labeled" />

or you can set it programatically.

Note: if you are upgrading from an older version of support library, do not forget to raise compile SDK version. Check versions of support libraray here: Support Library versions

However, you may still get labelVisibilityMode not found message when compile, if your app depends on older versions of the design support library. If this is the case, try to upgrade to a version of the given dependency, that depends on at least the version of 28.0.0-alpha1 of design support library. If that's not possible, define the dependency explicitly.

If you use Gradle

  1. You can check your depdendecies by running dependencies task and search for the version number of com.android.support:design.
  2. To add design support dependency explicitly in your build.gradle:

    implementation 'com.android.support:design:28.0.0'

查看更多
余生无你
6楼-- · 2019-01-01 05:26

update your support library to 28.0.0.

bottomNav.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED);
查看更多
长期被迫恋爱
7楼-- · 2019-01-01 05:26

If you are using support:design:28.0.0 add this line app:labelVisibilityMode="unlabeled" to your BottomNavigationView

查看更多
登录 后发表回答