Gradle
Add following dependency to your root project build.gradle file:
allprojects { repositories { maven { url "https://jitpack.io" } } }
Add following dependency to your app module build.gradle file:
dependencies { implementation 'com.github.KishanViramgama:Drawing:0.1.2' }
xml file
<RelativeLayout android:id="@+id/imageView" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@string/app_name"> <com.app.drawing.Util.CanvasView android:id="@+id/imageView" android:layout_width="match_parent" android:layout_height="match_parent"/> <ImageView android:id="@+id/imageView" android:layout_width="match_parent" android:layout_height="match_parent" android:contentDescription="@string/app_name" android:src="@mipmap/ic_app_icon"/> <RelativeLayout>
java file
private CanvasView customCanvas = findViewById(R.id.canvas_drawing); ImageView imageView = findViewById(R.id.imageView); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.image); imageView.setImageBitmap(bitmap); customCanvas.paintColor(getResources().getColor(R.color.colorAccent)); customCanvas.paintStork(20); customCanvas.clear();