本文介绍了BottomNavigationView原始图标颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有我的bottomNavigationView:

I have my bottomNavigationView :

我添加了此类,以防止其执行shiftingMode:

And i added this class to prevent it from doing shiftingMode :

public class BottomNavigationViewHelper {
    public static void disableShiftMode(BottomNavigationView view) {
        BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0);
        try {
            Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
            shiftingMode.setAccessible(true);
            shiftingMode.setBoolean(menuView, false);
            shiftingMode.setAccessible(false);
            for (int i = 0; i < menuView.getChildCount(); i++) {
                BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
                //noinspection RestrictedApi
                item.setShiftingMode(false);
                // set once again checked value, so view will be updated
                //noinspection RestrictedApi
                //item.setChecked(item.getItemData().isChecked());
            }
        } catch (NoSuchFieldException e) {
            Log.e("BNVHelper", "Unable to get shift mode field", e);
        } catch (IllegalAccessException e) {
            Log.e("BNVHelper", "Unable to change value of shift mode", e);
        }
    }

我只想在没有此选择器的情况下显示原始图标的颜色,我该如何做到这一点?

I just want to show the original icons colors without this selector, how i can reach this ?

我的导航xml:

<android.support.design.widget.BottomNavigationView
        android:id="@+id/bottomNavigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:menu="@menu/my_navigation_item"
        android:layout_alignParentBottom="true"/>

推荐答案

您必须将项目图标的色调列表设置为null,您可以通过bootomNav来实现:

You have to make your item icon tint list null, You reach that from your bootomNav :

bottomNavigationView.setItemIconTintList(null);

这篇关于BottomNavigationView原始图标颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 18:43