Accepting Signature in Android App

Arief Bayu Purwanto
Bits and pieces of my mind
2 min readMar 17, 2020

There are times where we need to capture signatures in our app. I did in several of our internal apps. A few years ago, for our very first app that needs signatures, I tried to develop the feature by myself. It did pretty dry, just no match to the standart😅. So I went hunting and luckily, with the power of open-source, someone already created an awesome “signature library”.

In this writing, I’ll do the implementation using Kotlin.

First of all, like any modern library, we add it to our project via Gradle config.

implementation ‘com.github.gcacace:signature-pad:1.3.1’

Next, create an activity as a way to capture.

I recommend creating new activity for the sole purpose of capturing signatures instead of adding the view to already exists activity and add ImageView in existing activity for when we need to show one. This way, we reduce a lot of “signature-related” codes and only have to handle the resulting image.

And here we have the Kotlin codes.

The crux of above codes are as follows:

Add SignaturePad to view:

Initialize the SignaturePad:

signaturePad.setPenColor(Color.BLACK)
//the rest of the configuration can be found in library’s page

Handle saving the signature using SignaturePad.signatureBitmap. In this case, inside of saveButton click action:

And that’s all, folks!

You can find the codes on my GitHub repositories.

--

--

Arief Bayu Purwanto
Bits and pieces of my mind

Project Leader at AkuPeduli.org | Mozilla Representative | @bloggerngalam | @ariefbayu | blogging at https://ariefbayu.dev