Want to provide functionality to draw on an android device? You can use this Library.
Every Action is performed nativley, so you can expect the best possible performance.
Add this line in the build.gradle(app) file
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add this line in the build.gradle(app) file
dependencies {
.
.
implementation 'com.github.Luciferx86:DoodleCanvasLibrary:0.1.0-alpha3'
.
.
}
.
.
<com.luciferx86.doodlecanvaslibrary.DoodleCanvas
android:id="@+id/doodleCanvas"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
.
.
You can modify the canvas properties like current Paint color and Stroke Width.
DoodleCanvas canvas;
.
.
.
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.filters);
//get reference to canvas
canvas = findViewById(R.id.doodleCanvas);
}
.
.
canvas.setStrokeColor(Color.GREEN);
//set custom color
canvas.setStrokeColor(Color.parseColor("#00ffbf"));
// would recommend using something between 10f and 100f
canvas.setStrokeWidth(20f);
// true and false are self explanatory
canvas.canUserDraw(false);
// undo last path drawn
canvas.undoMove();
// simply sets the paint color to White, which acts as erasing
canvas.enableErasing();
// restores the last saved painting configuration
canvas.enablePainting();
// removes all paths on canvas
canvas.clearCanvas();