List of usage examples for android.graphics.drawable Drawable clearColorFilter
public void clearColorFilter()
From source file:Main.java
public static Drawable setClearFilter(Drawable draw) { draw.clearColorFilter(); draw.invalidateSelf(); return draw; }
From source file:Main.java
@SuppressLint("NewApi") public static void clearTint(final Drawable drawable) { drawable.clearColorFilter(); }
From source file:Main.java
private static void upEffect(View v) { //if(v.getBackground() == null) return; Drawable drwb; if (v instanceof ImageView) { drwb = ((ImageView) v).getDrawable(); } else {/*w w w . jav a 2s . c o m*/ drwb = v.getBackground(); } if (drwb == null) return; drwb.clearColorFilter(); v.invalidate(); }
From source file:com.waz.zclient.pages.main.profile.preferences.dialogs.AddPhoneNumberPreferenceDialogFragment.java
@TargetApi(Build.VERSION_CODES.KITKAT) private static void clearColorFilter(@NonNull Drawable drawable) { drawable.clearColorFilter(); if (Build.VERSION.SDK_INT == 21 || Build.VERSION.SDK_INT == 22) { // API 21 + 22 have an issue where clearing a color filter on a DrawableContainer // will not propagate to all of its children. To workaround this we unwrap the drawable // to find any DrawableContainers, and then unwrap those to clear the filter on its // children manually if (drawable instanceof InsetDrawable) { clearColorFilter(((InsetDrawable) drawable).getDrawable()); } else if (drawable instanceof DrawableWrapper) { clearColorFilter(((DrawableWrapper) drawable).getWrappedDrawable()); } else if (drawable instanceof DrawableContainer) { final DrawableContainer container = (DrawableContainer) drawable; final DrawableContainer.DrawableContainerState state = (DrawableContainer.DrawableContainerState) container .getConstantState(); if (state != null) { for (int i = 0, count = state.getChildCount(); i < count; i++) { clearColorFilter(state.getChild(i)); }/*from w w w . j a va 2 s.c o m*/ } } } }
From source file:Main.java
public static int PutImageTargetHeightColor(Canvas canvas, Drawable image, int x, int y, int height, int color, Mode porterDuff) {//from w w w .j av a 2 s . co m float scale = (float) height / (float) image.getIntrinsicHeight(); int width = (int) Math.round(image.getIntrinsicWidth() * scale); Rect oldBounds = image.getBounds(); image.setBounds(x, y, x + width, y + height); image.setColorFilter(color, porterDuff); image.draw(canvas); image.setBounds(oldBounds); image.clearColorFilter(); return width; }
From source file:Main.java
public static Drawable toGreyDrawable(Drawable drawable) { int w = drawable.getMinimumWidth(); int h = drawable.getMinimumHeight(); if (w <= 0 || h <= 0) { return drawable; }/*from w w w. j a v a 2 s .c o m*/ Rect bounds = drawable.getBounds(); Bitmap grey = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(grey); ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0); drawable.setColorFilter(new ColorMatrixColorFilter(cm)); drawable.setBounds(0, 0, w, h); drawable.draw(c); drawable.clearColorFilter(); drawable.setBounds(bounds); BitmapDrawable bd = new BitmapDrawable(grey); bd.setBounds(0, 0, w, h); return bd; }
From source file:Main.java
public static Drawable toGrey(Drawable drawable) { int w = drawable.getMinimumWidth(); int h = drawable.getMinimumHeight(); if (w <= 0 || h <= 0) { return drawable; }/* w ww . j a v a 2 s . c om*/ Rect bounds = drawable.getBounds(); Bitmap grey = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(grey); ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0); drawable.setColorFilter(new ColorMatrixColorFilter(cm)); drawable.setBounds(0, 0, w, h); drawable.draw(c); drawable.clearColorFilter(); drawable.setBounds(bounds); BitmapDrawable bd = new BitmapDrawable(grey); bd.setBounds(0, 0, w, h); return bd; }
From source file:android.support.v7.internal.widget.TintManager.java
public static void tintViewBackground(View view, TintInfo tint) { final Drawable background = view.getBackground(); if (tint.mTintList != null) { tintDrawableUsingColorFilter(background, tint.mTintList.getColorForState(view.getDrawableState(), tint.mTintList.getDefaultColor()), tint.mTintMode != null ? tint.mTintMode : DEFAULT_MODE); } else {// w w w.j ava2 s.co m background.clearColorFilter(); } }
From source file:xyz.berial.textinputlayout.TintManager.java
public static void tintViewBackground(View view, TintInfo tint) { final Drawable background = view.getBackground(); if (tint.mHasTintList || tint.mHasTintMode) { background.setColorFilter(createTintFilter(tint.mHasTintList ? tint.mTintList : null, tint.mHasTintMode ? tint.mTintMode : DEFAULT_MODE, view.getDrawableState())); } else {/* www. j ava 2 s . co m*/ background.clearColorFilter(); } if (Build.VERSION.SDK_INT <= 10) { // On Gingerbread, GradientDrawable does not invalidate itself when it's ColorFilter // has changed, so we need to force an invalidation view.invalidate(); } }
From source file:com.bilibili.magicasakura.utils.TintManager.java
public static void tintViewDrawable(View view, Drawable drawable, TintInfo tint) { if (view == null || drawable == null) return;//from w w w.j av a 2s . c o m if (tint.mHasTintList || tint.mHasTintMode) { drawable.mutate(); if (drawable instanceof ColorDrawable) { ((ColorDrawable) drawable).setColor(ThemeUtils.replaceColor(view.getContext(), tint.mTintList .getColorForState(view.getDrawableState(), tint.mTintList.getDefaultColor()))); } else { drawable.setColorFilter( createTintFilter(view.getContext(), tint.mHasTintList ? tint.mTintList : null, tint.mHasTintMode ? tint.mTintMode : DEFAULT_MODE, view.getDrawableState())); } } else { drawable.clearColorFilter(); } if (Build.VERSION.SDK_INT <= 23) { // On Gingerbread, GradientDrawable does not invalidate itself when it's ColorFilter // has changed, so we need to force an invalidation drawable.invalidateSelf(); } }