Code example for Canvas

Methods: drawRGBdrawRectrestoresavetranslate

0
        } 
 
        @Override 
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            canvas.drawRGB(255, 255, 255);
 
            canvas.save();
            canvas.translate(40.0f, 40.0f);
 
            mPaint.setShader(mComposeShader);
            canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint);
 
            canvas.translate(0.0f, 40.0f + mDrawHeight);
            mPaint.setShader(mCompose2Shader);
            canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint);
 
            canvas.translate(0.0f, 40.0f + mDrawHeight);
            mPaint.setShader(mCompose3Shader);
            canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint);
 
            canvas.restore();
 
            canvas.save();
            canvas.translate(40.0f + mDrawWidth + 40.0f, 40.0f);
 
            mPaint.setShader(mCompose4Shader);
            canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint);
 
            canvas.translate(0.0f, 40.0f + mDrawHeight);
            mPaint.setShader(mCompose5Shader);
            canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint);
 
            canvas.translate(0.0f, 40.0f + mDrawHeight);
            mPaint.setShader(mCompose6Shader);
            canvas.drawRect(0.0f, 0.0f, mDrawWidth, mDrawHeight, mPaint);
 
            canvas.restore();
        } 
    } 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE