zahid-ali-shah / SignatureView

SignatureView is an open source Android library which allow developers to produce pen and paper like effect for creating signatures on Android
Apache License 2.0
243 stars 68 forks source link

Pen colour not working #10

Closed DharmbirChoudhary closed 6 years ago

DharmbirChoudhary commented 6 years ago

Pen colour not working in either XML or Code

sign:penColor="@color/colorPrimary"

signatureView.setPenColor(R.color.colorPrimary);

Both not working, Always using black colour. Please have a look on this issue. I am using Android OS 4.2.1

zahid-ali-shah commented 6 years ago

You can set color in code like this

int colorPrimary = ContextCompat.getColor(mContext, R.color.colorPrimary);
signatureView.setPenColor(colorPrimary);

// or like signatureView.setPenColor(Color.RED);

It also works in xml see penColor

<com.kyanogen.signatureview.SignatureView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:sign="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    sign:enableSignature="true"
    sign:penSize="3dp"
    sign:backgroundColor="#ffffff"
    sign:penColor="@color/colorAccent"/>

If this does not work for you then provide complete information i.e. Android device name, model, OS and code sample.