Changes the paint color to the specified value. - Android Graphics

Android examples for Graphics:Color Value

Description

Changes the paint color to the specified value.

Demo Code

// Copyright 2009-2011 Google, All Rights reserved
//package com.java2s;
import android.graphics.Paint;

public class Main {
    /**//from w  ww .  j  a v a2  s .c o  m
     * Changes the paint color to the specified value.
     *
     * @param paint the object to mutate with the new color
     * @param argb a 32-bit integer with eight bits for alpha, red, green, and blue,
     *        respectively
     */
    public static void changePaint(Paint paint, int argb) {
        // TODO(user): can the following two lines can be replaced by:
        // paint.setColor(argb)?
        paint.setColor(argb & 0x00FFFFFF);
        paint.setAlpha((argb >> 24) & 0xFF);
        paint.setXfermode(null);
    }
}

Related Tutorials