问题
I Started working on Android Bottom Navigation View. But i am facing one issue. If i added 5 items to bottom navigation view, only selected items showing item text. If i added 3 items it is working fine. Any one please tell me how to show the item text for all the 5 items. Thank you in advance.
menu.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.reloadapp.reload.activity.IconTabsActivity">
<item
android:id="@+id/action_favorites"
android:enabled="true"
android:icon="@drawable/home_40"
android:title="Home"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_schedules"
android:enabled="true"
android:icon="@drawable/profile_40"
android:title="Profile"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_music"
android:enabled="true"
android:icon="@drawable/reload_40"
android:title="Reload cash"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_musi"
android:enabled="true"
android:icon="@drawable/notifications"
android:title="Notifications"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_mus"
android:enabled="true"
android:icon="@drawable/menu_40"
android:title="More"
app:showAsAction="ifRoom" />
</menu>
dependency: compile 'com.android.support:appcompat-v7:25.0.1' compile 'com.android.support:design:25.0.0'
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:itemBackground="@color/textColorPrimary"
app:menu="@menu/menu_icon_tabs"
app:itemIconTint="@color/colorPrimary"
app:itemTextColor="@color/colorPrimary"
android:layout_alignParentBottom="true">
</android.support.design.widget.BottomNavigationView>
回答1:
Remove animation in bottom navigation ,use this code
navigation = (BottomNavigationView) findViewById(R.id.navigation);
disableShiftMode(navigation);
method
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);
}
}
UPDATE:
you can change menu text size like this How to change the Menu text size
来源:https://stackoverflow.com/questions/43491741/android-bottom-navigation-view-item-text-color