Code example for Canvas

Methods: drawRectrestoresavesaveLayerscaletranslate

0
        /* 
         * Save a layer so that we can render off screen initially in order to 
         * achieve the DST_OUT xfer mode.  This allows us to have a non-solid 
         * background. 
         */ 
        canvas.saveLayer(child.getLeft(), child.getBottom(), child.getRight(),
                child.getBottom() + getBottom(),
                null, Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
 
        /* Draw the flipped child. */ 
        canvas.save();
        canvas.scale(1, -1);
        canvas.translate(0, -(childh * 2));
        child.draw(canvas);
        canvas.restore();
 
        /* Saturate the flipped image with a dark color. */ 
        canvas.drawRect(0, childh, childw, selfh, mDarkPaint);
 
        /* Carve out the reflection area's alpha channel. */ 
        mMatrix.setScale(1, poolh);
        mMatrix.postTranslate(0, childh);
        mShader.setLocalMatrix(mMatrix);
        canvas.drawRect(0, childh, childw, selfh, mReflectionPaint);
 
        /* Apply the canvas layer. */ 
        canvas.restore();
    } 
} 
Connect your IDE to all the code out there  Get Codota for Java