This fork just addresses the TransactionTooLarge Exception issue. This fork just prevents saving state, thus leading to state loss. Feature introductions aren't guaranteed.
Latest version of the library can be found on Maven Central.
Open your build.gradle
and make sure that Maven Central repository is declared into repositories
section:
repositories {
maven { url 'https://jitpack.io' }
}
Then, include the library as dependency:
compile 'com.github.ZupersoftSolutions:signature-pad:1.3.2'
Please see the /SignaturePad-Example
app for a more detailed code example of how to use the library.
- Add the
SignaturePad
view to the layout you want to show.
<com.github.gcacace.signaturepad.views.SignaturePad
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/signature_pad"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:penColor="@android:color/black"
/>
- Configure attributes.
penMinWidth
- The minimum width of the stroke (default: 3dp).penMaxWidth
- The maximum width of the stroke (default: 7dp).penColor
- The color of the stroke (default: Color.BLACK).velocityFilterWeight
- Weight used to modify new velocity based on the previous velocity (default: 0.9).clearOnDoubleClick
- Double click to clear pad (default: false)
- Configure signature events listener
An OnSignedListener
can be set on the view:
mSignaturePad = (SignaturePad) findViewById(R.id.signature_pad);
mSignaturePad.setOnSignedListener(new SignaturePad.OnSignedListener() {
@Override
public void onStartSigning() {
//Event triggered when the pad is touched
}
@Override
public void onSigned() {
//Event triggered when the pad is signed
}
@Override
public void onClear() {
//Event triggered when the pad is cleared
}
});
- Get signature data
getSignatureBitmap()
- A signature bitmap with a white background.getTransparentSignatureBitmap()
- A signature bitmap with a transparent background.getSignatureSvg()
- A signature Scalable Vector Graphics document.
The SignaturePad
view has custom Data Binding attribute setters for all the listener events:
<com.github.gcacace.signaturepad.views.SignaturePad
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bind="http://schemas.android.com/apk/res-auto"
android:id="@+id/signature_pad"
android:layout_width="match_parent"
android:layout_height="match_parent"
bind:onStartSigning="@{activity.onStartSigning}"
bind:onSigned="@{activity.onSigned}"
bind:onClear="@{activity.onClear}" />
Thanks to netinhoteixeira, there is a Cordova plugin using that library. Please refer to https://github.com/netinhoteixeira/cordova-plugin-signature-view.
Thanks to bradmartin, there is a NativeScript plugin. Please refer to https://github.com/bradmartin/nativescript-signaturepad.
Currently doesn't support screen rotations. Pull requests are welcome!
Copyright 2014-2016 Gianluca Cacace
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.