set Drawable Tint - Android Graphics

Android examples for Graphics:Drawable Tint

Description

set Drawable Tint

Demo Code


//package com.java2s;

import android.graphics.PorterDuff;

import android.graphics.drawable.Drawable;

import android.os.Build;

public class Main {
    public static void setTint(Drawable drawable, int color) {
        if (Build.VERSION.SDK_INT >= 21) {
            drawable.setTint(color);//from www . ja  va  2s .c o m
        } else {
            drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
        }
    }
}

Related Tutorials