set Compound Drawable Filter - Android Graphics

Android examples for Graphics:Drawable Filter

Description

set Compound Drawable Filter

Demo Code


import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.widget.TextView;

public class Main {

  public static void setCompoundDrawableFilter(TextView textView, int duration, int color) {
    Drawable[] drawables = textView.getCompoundDrawables();
    if (null != textView) {
      setDrawableFilter(drawables[duration], color);
    }/*from  w w w.j  a  va 2  s.  com*/
  }

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

Related Tutorials