问题描述:https://blog.csdn.net/jingbin_/article/details/103189201
我遇到的情况类似,也是小米手机
解决方案:自定义TextView在构造方法里判断又没有设置方法,没有的话就设置默认颜色,然后全局替换TextView即可
import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
public class SupperTextView extends android.support.v7.widget.AppCompatTextView {
public SupperTextView(Context context) {
super(context);
init(context, null);
}
public SupperTextView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
public SupperTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs);
}
private void init(Context context, AttributeSet attrs) {
if (attrs != null) {
int[] styleable = new int[]{
android.R.attr.textColor // 3
};
TypedArray array = context.obtainStyledAttributes(attrs, styleable);
//<color name="tv_def_color">#FF888888</color>
int color = array.getColor(0, UIUtils.getColor(R.color.tv_def_color));
setTextColor(color);
XLog.showArgsInfo(color);
array.recycle();
}
}
}