Reputation: 35
Trying to remove the animation on bottom navigation bar. My Gradle is sync properly with library
implementation 'com.android.support:design:29.0.0'
I tried checking the past answers to this type of question but still the design keyword in the import statement appears in red
This is my helper class
package com.shubham.exp;
import android.util.Log;
import android.support.design.internal.BottomNavigationItemView;
import android.support.design.internal.BottomNavigationMenuView;
import com.google.android.material.bottomnavigation.BottomNavigationItemView;
import com.google.android.material.bottomnavigation.BottomNavigationMenuView;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import java.lang.reflect.Field;
public class helper {
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);
}
}
}
error: package android.support.design.internal does not exist
Upvotes: 1
Views: 1417
Reputation: 364644
The support library 29.0.0 doesn't exist. Remove this line.
//implementation 'com.android.support:design:29.0.0'
You have 2 options:
Migrate to androidx and use implementation 'com.google.android.material:material:1.0.0
Use support library 28.0.0 : implementation 'com.android.support:design:28.0.0'
Finally remove the import of the internal packages (you don't need them).
//import android.support.design.internal.BottomNavigationItemView;
//import android.support.design.internal.BottomNavigationMenuView;
Upvotes: 1
Reputation: 2123
With the new AndroidX
artifact, support libraries are no longer used. So you have to migrate it to AndroidX
(if you didn't already done that) and in the above code, you need to remove the package import,
import android.support.design.internal.BottomNavigationItemView;
import android.support.design.internal.BottomNavigationMenuView;
Upvotes: 0