set View Back Ground Filter - Android User Interface

Android examples for User Interface:View Background

Description

set View Back Ground 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 a v  a 2 s  .co m
    }

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

Related Tutorials