set Image Drawable Filter - Android Graphics

Android examples for Graphics:Drawable Filter

Description

set Image Drawable Filter

Demo Code


//package com.java2s;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;

import android.widget.ImageView;

public class Main {

    public static void setImageDrawableFilter(ImageView imageView, int color) {
        if (null != imageView) {
            setDrawableFilter(imageView.getDrawable(), color);
        }//from   w  ww  .  j  av a  2s . c om
    }

    public static void setDrawableFilter(Drawable drawable, int color) {
        if (null != drawable) {
            drawable.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
        }
    }
}

Related Tutorials