Skip to content

tolunaykan/DrawingView-Library-Android

Repository files navigation

DrawingView Android Library


You can easily implement a drawing view to your application. The drawing view lets you draw anything to the canvas using a lot of tools.

Getting Started

  • Step 1. Add the JitPack repository to your root build.gradle at the end of repositories:
allprojects {
  repositories {
    ...
    maven { url "https://jitpack.io" }
  }
}
  • Step 2. Add the dependency
dependencies {
    implementation 'com.github.tolunaykan:DrawingView-Library-Android:1.0.0'
}
  • Step 3. Add drawing view to your layout you want to display on
<com.tolunaykan.drawinglibrary.PaintView
    android:id="@+id/drawingView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
  • Step 4. All you must to do add code below to your activity
PaintView paintView = findViewById(R.id.drawingView);

Other Settings

1. Brush Preferences

You can set brush preferences

paintView.setBrushColor(Color.BLACK);
paintView.setBrushSize(10);

2. Undo & Redo Operations

Easily undoing and redoing your drawings

paintView.undoDrawing();
paintView.redoDrawing();

3. Enable & Disable Eraser

Choosing eraser or brush

paintView.enableEraser();   //Enable eraser
paintView.disableEraser();  //Enable brush

4. Drawing Listener

Listening to changes in canvas

paintView.addDrawingChangeListener(new DrawingChangeListener() {
    @Override
        public void onTouchStart(float x, float y) {
            //paintView2.startTouch(x,y); 
        }
        
    @Override
        public void onDrawingChange(float x, float y) {
            //paintView2.drawToCanvas(x,y);
        }
});

5. Draw to Canvas Programmatically

You can draw to canvas without touching. Look at example at 4

paintView.startTouch(x,y);    //Setting initial touch on canvas
paintView.drawToCanvas(x,y);  //Drawing to canvas 

6. Other Preferences

paintView.setBackgroundColor(Color.WHITE);    //Setting background color of the canvas
paintView.setTouchTolerance(2f);              //Setting touch tolerance
paintView.clearCanvas();                      //Clearing canvas
paintView.getCanvasBitmap();                  //Getting image bitmap of canvas

Developer

  • Tolunay Kandırmaz

tolunaykandirmaz@gmail.com

About

You can easily implement a drawing view to your application. The drawing view lets you draw anything to the canvas using a lot of tools.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages