private static boolean tintDrawableUsingColorFilter(@NonNull Context context, @DrawableRes int resId, @NonNull Drawable drawable) {
Mode tintMode = DEFAULT_MODE;
boolean colorAttrSet = false;
int colorAttr = 0;
int alpha = -1;
if (arrayContains(COLORFILTER_TINT_COLOR_CONTROL_NORMAL, resId)) {
colorAttr = R.attr.colorControlNormal;
colorAttrSet = true;
} else if (arrayContains(COLORFILTER_COLOR_CONTROL_ACTIVATED, resId)) {
colorAttr = R.attr.colorControlActivated;
colorAttrSet = true;
} else if (arrayContains(COLORFILTER_COLOR_BACKGROUND_MULTIPLY, resId)) {
colorAttr = 16842801;
colorAttrSet = true;
tintMode = Mode.MULTIPLY;
} else if (resId == R.drawable.abc_list_divider_mtrl_alpha) {
colorAttr = 16842800;
colorAttrSet = true;
alpha = Math.round(40.8f);
}
if (!colorAttrSet) {
return false;
}
if (DrawableUtils.canSafelyMutateDrawable(drawable)) {
drawable = drawable.mutate();
}
drawable.setColorFilter(getPorterDuffColorFilter(ThemeUtils.getThemeAttrColor(context, colorAttr), tintMode));
if (alpha != -1) {
drawable.setAlpha(alpha);
}
return true;
}
AppCompatDrawableManager.java 文件源码
java
阅读 35
收藏 0
点赞 0
评论 0
项目:boohee_v5.6
作者:
评论列表
文章目录