androidx.core.graphics.drawable.TintAwareDrawable Java Examples
The following examples show how to use
androidx.core.graphics.drawable.TintAwareDrawable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Carbon.java From Carbon with Apache License 2.0 | 5 votes |
public static void setTint(Drawable drawable, int tint) { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { drawable.setTint(tint); } else if (drawable instanceof TintAwareDrawable) { ((TintAwareDrawable) drawable).setTint(tint); } else { drawable.setColorFilter(new PorterDuffColorFilter(tint, PorterDuff.Mode.SRC_IN)); } }
Example #2
Source File: Carbon.java From Carbon with Apache License 2.0 | 5 votes |
public static void setTintListMode(Drawable drawable, ColorStateList tint, PorterDuff.Mode mode) { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { drawable.setTintList(tint); drawable.setTintMode(mode); } else if (drawable instanceof TintAwareDrawable) { ((TintAwareDrawable) drawable).setTintList(tint); ((TintAwareDrawable) drawable).setTintMode(mode); } else { drawable.setColorFilter(tint == null ? null : new PorterDuffColorFilter(tint.getColorForState(drawable.getState(), tint.getDefaultColor()), mode)); } }
Example #3
Source File: Carbon.java From Carbon with Apache License 2.0 | 5 votes |
public static void clearTint(Drawable drawable) { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { drawable.setTintList(null); } else if (drawable instanceof TintAwareDrawable) { ((TintAwareDrawable) drawable).setTintList(null); } else { drawable.setColorFilter(null); } }