2
私は私のbottomNavigationView持っている:BottomNavigationViewオリジナルのアイコンの色
を、私は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);
}
}
私はちょうどずに、元のアイコンの色を表示したいですこのセレクタ、私はこれにどのように到達することができますか?
私のナビゲーションのxml:あなたは、あなたのアイテムアイコンの色合いリストnull
をしなければならない
<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"/>
おかげで、それが動作します!私はapp:itemIconTint = "@ null"をXMLに追加しようとしましたが、機能しません。 – NightSkyDev