set View BackGround Filter - Android User Interface

Android examples for User Interface:View Background

Description

set View BackGround Filter

Demo Code


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

import android.view.View;

public class Main {

    public static void setBackGroundFilter(View view, int color) {
        if (null != view) {
            setDrawableFilter(view.getBackground(), color);
        }/*from  w w  w.  j av  a  2 s  .c om*/
    }

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

Related Tutorials