BottomNavigationView doesn't allow disabling shift mode has this issue fixed in new version of support library?
Also there are some solutions which use reflection mechanism I don't think its right way is there any solution to this major problem.
BottomNavigationView doesn't allow disabling shift mode has this issue fixed in new version of support library?
Also there are some solutions which use reflection mechanism I don't think its right way is there any solution to this major problem.
If possible then update to android sdk-28 then add app:labelVisibilityMode="labeled"
in your xml.
You just need to update to 28.0.0 support library! They already provided setLabelVisibilityMode() method to disable the shifting
navButton.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED);
for more info, check this out https://developer.android.com/reference/com/google/android/material/bottomnavigation/LabelVisibilityMode.html#LABEL_VISIBILITY_SELECTED
Hello I have face the same problem and I know that its tedious task to load reflect java library in xamarin android.
But thanks to "James Montemagno" to come with its solution. Here is the link you can follow and got the result you want!
It worked for me hope it will for you too. Happy coding! :)
Link: https://montemagno.com/remove-shifting-bottomnavigationview-android/
public static class BottomNavigationViewUtils {
/// <summary>
/// Enable or disable shift mode on bottom navigation view
/// </summary>
public static void SetShiftMode(this BottomNavigationView bottomNavigationView, bool enableShiftMode, bool enableItemShiftMode)
{
try
{
var menuView = bottomNavigationView.GetChildAt(0) as BottomNavigationMenuView;
if (menuView == null)
{
System.Diagnostics.Debug.WriteLine("Unable to find BottomNavigationMenuView");
return;
}
var shiftMode = menuView.Class.GetDeclaredField("mShiftingMode");
shiftMode.Accessible = true;
shiftMode.SetBoolean(menuView, enableShiftMode);
shiftMode.Accessible = false;
shiftMode.Dispose();
for (int i = 0; i < menuView.ChildCount; i++)
{
var item = menuView.GetChildAt(i) as BottomNavigationItemView;
if (item == null)
continue;
item.SetShiftingMode(enableItemShiftMode);
item.SetChecked(item.ItemData.IsChecked);
}
menuView.UpdateMenuView();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Unable to set shift mode: {ex}");
}
}
}
Than Use it:
var bottomNavigationView = FindViewById(Resource.Id.bottomNavigationBar); bottomNavigationView.SetShiftMode(false,false);
Just add this in your dimens.. worked for me!
<dimen name="design_bottom_navigation_active_text_size">12sp</dimen>