A simple view to draw on supporting:
- undo, redo, eraser, clear
- set brush color and size
- set callback listeners for drawing and canvas state changes
Simply create view in your code or in xml and you're good to go.
Make sure root build.gradle repositories include JitPack
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}And DrawingView dependency is added to app build.gradle
dependencies {
implementation 'com.github.mvojtkovszky:DrawingView:$latest_version'
}By default, DrawingView preserves its original behavior and accepts coordinates from a gesture that moves outside its bounds. Enable clamping when adjacent UI must never contain drawing data:
<com.vojtkovszky.drawingview.DrawingView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:clampDrawingToBounds="true" />Or configure it programmatically:
drawingView.clampDrawingToBounds = true