Code example for PorterDuffColorFilter

0
     * @param filter The filter color to be applied using SRC_OVER mode. 
     */ 
    public void setColorWithFilter(int color, int filter) {
        mColorPaint = new Paint(mPaint);
        mColorPaint.setColor(color);
        mColorPaint.setColorFilter(new PorterDuffColorFilter(filter, PorterDuff.Mode.SRC_OVER));
    } 
 
    /** 
     * Set the alpha for the linear gradient used with the bitmap's shader. 
     * 
     * @param startAlpha The starting alpha (0..255) value to be applied to the LinearGradient. 
     * @param startAlpha The ending alpha (0..255) value to be applied to the LinearGradient. 
     */ 
    public void setAlpha(int startAlpha, int endAlpha) {
        mStartColor = startAlpha << 24;
        mEndColor = endAlpha << 24;
        initializeBitmapShader(); 
    } 
 
    private void initializeBitmapShader() {