Code example for Canvas

Methods: clipRectdrawBitmapdrawRectrestoresave

0
 
        float w = getWidth();
        float h = getHeight();
 
        // Clear the buffer canvas 
        mBufferCanvas.drawRect(0, 0, w, h, mClearPaint);
 
        // Set its clip so we don't draw the front image all the way to the top 
        Rect clip = new Rect(0,
                (int) ((1.0 - mLevel) * (h + mEdgeBitmapOffset)) - mEdgeBitmapOffset,
                (int) w,
                (int) h);
 
        mBufferCanvas.save();
        mBufferCanvas.clipRect(clip);
 
        // Draw the front image 
        mFrontDrawable.setBounds(new Rect(0, 0, (int) w, (int) h));
        mFrontDrawable.draw(mBufferCanvas);
 
        mBufferCanvas.restore();
 
        // Draw the edge image on top of the buffer image with a multiply mode 
        mBufferCanvas.drawBitmap(mEdgeBitmap, 0, clip.top, mMultPaint);
 
        // Draw the buffer image (on top of the background image) 
        canvas.drawBitmap(mDrawingBuffer, 0, 0, null);
    } 
 
Contextual code suggestions in your IDE  Get Codota for Java