Quantcast
Channel: Microsoft Dynamics 365 Community
Viewing all articles
Browse latest Browse all 17314

Using Xamarin’s Signature Pad in Android apps

$
0
0

Xamarin’s Signature Pad control makes adding, changing, opening and saving signatures much easier. This example will show how to do basic operations like loading a signature from an array of points, saving a signature as an array of bytes, and exporting users' signatures as an image.

Firstly, the Signature Pad should be declared in the containing activity and added to the view. The view declaration of the Signature Pad can look something like this:


In the activity, declare the SignatureView variable, so it can be populated and used for later operations:


The Signature Pad control should then be found and assigned to the SignatureView variable in the OnCreate function:

Now that we have the SignatureView initialized, there are several useful methods that can be used for displaying, saving and getting the signature image.


In the previous code, the point array is randomly generated. Every point is assigned with its x and y coordinate, which is an int value, and has a special location in the Signature Pad view. The Signature Pad will display the generated points via the LoadPoints method.

The Points property of the Signature Pad holds an array of points that are currently drawn on the Signature Pad view. This enables saving the point array for later use or display at the Signature Pad.

The Signature Pad can retrieve a Bitmap of the currently displayed signature via GetImage function. It’s a good practice to limit the size of the image that is retrieved, by passing a size property to the GetImage method, since java Signature Pad exception can occur in case of getting large data sets. At last, the retrieved image can be stored as a Bitmap or more conveniently, as a byte array, for saving and future use.


Viewing all articles
Browse latest Browse all 17314

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>