Reputation: 1123
After upgrading support library to v-28.0.0
BottomNavigationView
shift mode not disabling. Even I am using app:labelVisibilityMode="labeled"
but items are shifting & item text gets cut on selection.
Previously I was using reflections to do this. Is there any other way to disable shift mode.
Upvotes: 1
Views: 1517
Reputation: 165
To me, in XML enable the shifting mode used, with match_parent width
app:labelVisibilityMode="selected"
Disable shifting mode used
app:labelVisibilityMode="labeled"
& remove your reflections. Mine works as usual.
Upvotes: 3
Reputation: 1317
Try setting app:itemTextAppearanceActive
and app:itemTextAppearanceInactive
to the same textAppearance style, or ones that have the same textSize
and fontFamily
Upvotes: 0
Reputation: 395
maybe this can help (it's kotlin) :
@SuppressLint("RestrictedApi")
fun disableShiftMode(view: BottomNavigationView) {
val menuView = view.getChildAt(0) as BottomNavigationMenuView
try {
val shiftingMode = menuView.javaClass.getDeclaredField("mShiftingMode")
shiftingMode.isAccessible = true
shiftingMode.setBoolean(menuView, false)
shiftingMode.isAccessible = false
for (i in 0 until menuView.childCount) {
val item = menuView.getChildAt(i) as BottomNavigationItemView
item.setShiftingMode(false)
// set once again checked value, so view will be updated
item.setChecked(item.itemData.isChecked)
}
} catch (e: NoSuchFieldException) {
Log.e(TAG, "Unable to get shift mode field")
} catch (e: IllegalAccessException) {
Log.e(TAG, "Unable to change value of shift mode");
}
}
Upvotes: 0