Skip to content

Instantly share code, notes, and snippets.

@ArtemSharypov
ArtemSharypov / DrawingView.java
Created November 25, 2018 18:17
Android View that allows for drawing or painting lines. It supports changing colours, increasing or decreasing the width of the stroke, as well using a bitmap as a starting place for the view/drawing. It also will apply the new additions to the drawing once a user stops touching the screen. It does not support a undo, or redo functionality.
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;