项目作者: imabhishekkumar

项目描述 :
Android view that lets you draw on it. 🖌🎨
高级语言: Kotlin
项目地址: git://github.com/imabhishekkumar/CanvasView.git
创建时间: 2019-10-27T08:13:34Z
项目社区:https://github.com/imabhishekkumar/CanvasView

开源协议:

下载


CanvasView

Android library that lets you draw on it.

Add library to project:

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. }

Step 2. Add the dependency

  1. dependencies {
  2. implementation 'com.github.imabhishekkumar:CanvasView:1.0'
  3. }

Implementation

In XML layout

  1. <dev.abhishekkumar.canvasview.CanvasView
  2. android:id="@+id/canvasView"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"></dev.abhishekkumar.canvasview.CanvasView>

Set background color, marker color, and stroke width

  1. val canvasView = findViewById<CanvasView>(R.id.canvasView)
  2. canvasView.setColorBackground(R.color.colorPrimary)
  3. canvasView.setColorMarker(R.color.colorAccent)
  4. canvasView.setStrokeWidth(12f)

Get/Set Bitmap from/to view

  1. canvasView.getBitmap()
  2. canvasView.setBitmap(bitmap)

Clear view

  1. canvasView.clearView()