Open OkamiyGit opened 2 years ago
还维护吗?
自己动手吧 ,导出来替换一下 高版本 没有这个属性了.TintTypedArray a = ThemeEnforcement.obtainTintedStyledAttributes(context, attrs, android.support.design.R.styleable.BottomNavigationView, defStyleAttr, android.support.design.R.style.Widget_Design_BottomNavigationView, new int[]{android.support.design.R.styleable.BottomNavigationView_itemTextAppearanceInactive, android.support.design.R.styleable.BottomNavigationView_itemTextAppearanceActive});
替换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(); }
我先试试 看看行不行
@gyyak46 我尝试了下,可以运行,但按钮图标会消失。
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();
}
}
compileSdk 31 targetSdk 31
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.2' implementation 'androidx.navigation:navigation-ui-ktx:2.4.2' implementation 'com.google.android.material:material:1.5.0'
这个版本报错,版主可以更新维护一下吗?