Code example for Canvas

Methods: clipPath, drawARGB, restore, save, translate

0
            mClipPath.addCircle(0.0f, 0.0f, getWidth() / 4.0f, Path.Direction.CW);
        } 
 
        @Override 
        protected void dispatchDraw(Canvas canvas) {
            canvas.drawARGB(255, 255, 255, 255);
 
            canvas.save(Canvas.MATRIX_SAVE_FLAG);
            canvas.translate(mClipPosition * getWidth(), getHeight() / 2.0f);
            canvas.clipPath(mClipPath);
            canvas.restore();
 
            super.dispatchDraw(canvas);
 
            invalidate();
        } 
    } 
 
    private static final String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sagittis molestie aliquam. Donec metus metus, laoreet nec sagittis vitae, ultricies sit amet eros. Suspendisse sed massa sit amet felis consectetur gravida. In vitae erat mi, in egestas nisl. Phasellus quis ipsum massa, at scelerisque arcu. Nam lectus est, pellentesque eget lacinia non, congue vitae augue. Aliquam erat volutpat. Pellentesque bibendum tincidunt viverra. Aliquam erat volutpat. Maecenas pretium vulputate placerat. Nulla varius elementum rutrum. Aenean mollis blandit imperdiet. Pellentesque interdum fringilla ligula.";
}