Open haemi opened 2 years ago
@haemi Did you able to fix it?
me too,i also have difficulty in here
Copy the files BottomNavigationViewEx.java
and BottomNavigationViewInner.java
to your project, then in BottomNavigationViewInner.java
make the styleable like this:
public BottomNavigationViewInner(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TintTypedArray a = ThemeEnforcement.obtainTintedStyledAttributes(context, attrs,
com.google.android.material.R.styleable.BottomNavigationView,
defStyleAttr, com.google.android.material.R.style.Widget_Design_BottomNavigationView,
new int[]{com.google.android.material.R.styleable.NavigationBarView_itemTextAppearanceInactive,
com.google.android.material.R.styleable.NavigationBarView_itemTextAppearanceActive});
// clear if you don't have set item icon tint list
if (!a.hasValue(com.google.android.material.R.styleable.NavigationBarView_itemIconTint)) {
clearIconTintColor();
}
a.recycle();
}
Changes for:
com.google.android.material.R.styleable.NavigationBarView_itemTextAppearanceInactive
com.google.android.material.R.styleable.NavigationBarView_itemTextAppearanceActive
com.google.android.material.R.styleable.NavigationBarView_itemIconTint
1.
BottomNavigationViewInner中
private BottomNavigationItemView[] mButtons;
改为
private NavigationBarItemView[] mButtons;
对应修改BottomNavigationViewEx方法返回值
2.构造方法
public BottomNavigationViewInner(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TintTypedArray a = ThemeEnforcement.obtainTintedStyledAttributes(context, attrs,
com.google.android.material.R.styleable.BottomNavigationView,
defStyleAttr, com.google.android.material.R.style.Widget_Design_BottomNavigationView,
com.google.android.material.R.styleable.NavigationBarView_itemTextAppearanceInactive,
com.google.android.material.R.styleable.NavigationBarView_itemTextAppearanceActive);
// clear if you don't have set item icon tint list
if (!a.hasValue(com.google.android.material.R.styleable.NavigationBarView_itemIconTint)) {
clearIconTintColor();
}
a.recycle();
}
3.修改如下方法
private <T> T getField(Class targetClass, Object instance, String fieldName) {
try {
Field field = null;
while (targetClass != null && !targetClass.getName().toLowerCase().equals("java.lang.object")) {
for (Field f : targetClass.getDeclaredFields()) {
if (f.getName().equals(fieldName)) {
field = f;
break;
}
}
if (field != null)
break;
targetClass = targetClass.getSuperclass(); //得到父类,然后赋给自己
}
if (field == null)
return null;
// Field field = targetClass.getDeclaredField(fieldName);
field.setAccessible(true);
return (T) field.get(instance);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private void setField(Class targetClass, Object instance, String fieldName, Object value) {
try {
Field field = null;
while (targetClass != null && !targetClass.getName().toLowerCase().equals("java.lang.object")) {
for (Field f : targetClass.getDeclaredFields()) {
if (f.getName().equals(fieldName)) {
field = f;
break;
}
}
if (field != null)
break;
targetClass = targetClass.getSuperclass(); //得到父类,然后赋给自己
}
if (field == null)
return;
// Field field = targetClass.getDeclaredField(fieldName);
field.setAccessible(true);
field.set(instance, value);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
After updating my kotlin version I get
What am I missing here?
Kotlin 1.7.0 Google Material 1.6.1