SignatureView is an open source Android library which allow developers to produce pen and paper like effect for creating signatures on Android
This is just an updated version of SignatureView and applying some of the active pull requests in it. Credits go completely to its creator and the people who has contributed with those pull requests.
-
Step 1. Add the JitPack repository to your build file
Add it in 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.leodan11:SignatureView:Tag' }
-
Step 2. Add the dependency
dependencies { implementation("com.github.leodan11:SignatureView:$Tag") }
SignatureView offers several attributes for a deeper view configuration, the following table shows all these options and their default value.
| Name | Description | Values | Default |
|---|---|---|---|
| signature_view_toBackgroundColor | Set background color | color | Color.WHITE |
| signature_view_toEnable | Enable/disable drawing signature on view | boolean | true |
| signature_view_toPenColor | Set pen stroke color | color | Color.BLACK |
| signature_view_toPenSize | Set pen stroke size | dimension | 3dp |
- Include SignatureView in a layout xml file:
<com.github.leodan11.view.SignatureView
android:id="@+id/signature_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.github.leodan11.view.SignatureView
android:id="@+id/signature_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:toBackgroundColor="?attr/backgroundColor"
app:toEnable="true"
app:toPenColor="?attr/colorPrimary"
app:toPenSize="3dp" />- Include SignatureView:
val signatureView: SignatureView = findViewById(R.id.signature_view)- Clear screen
signatureView.clearCanvas()- Is Bitmap Empty
//Kotlin
signatureView.isBitmapEmpty//Java
Boolean isEmpty = signatureView.isBitmapEmpty();- Get SignatureView as bitmap
//Kotlin
val bitmap: Bitmap = signatureView.signatureBitmap//Java
Bitmap bitmap = signatureView.getSignatureBitmap();