Skip to content

Repository files navigation

VerifyCodeView

VerifyCodeView is a android view for inputting Verification Code.

Features

  • Numerical verification code.

  • Customize appearance of border.

  • Automatic fill verification code by SMS.

ScreenCapture

CircleView

Dependency

  • Gradle

dependencies {
compile 'com.github.gongw:verifycodeview:1.0.2'
}
  • Maven

<dependency>
<groupId>com.github.gongw</groupId>
<artifactId>verifycodeview</artifactId>
<version>1.0.2</version>
<type>pom</type>
</dependency>

Attributes

  • vcTextCount - The verification code text count.
  • vcTextColor - The verification code text color.
  • vcTextSize - The verification code text size by sp.
  • vcTextFont - The verification code text font path in assets.
  • vcDividerWidth - The divider width by dp between verify code item.
  • vcWrapper - The wrapper contains verify code.
  • vcWrapperStrokeWidth - The stroke width of wrapper by dp.
  • vcWrapperColor - The color of wrapper.
  • vcNextWrapperColor - The color of wrapper which is the next one to be filled.

Example

  • xml

<com.github.gongw.VerifyCodeView
android:layout_width="240dp"
android:layout_height="50dp"
android:layout_marginTop="42dp"
app:vcTextColor="#b63b21"
app:vcTextCount="4"
app:vcTextSize="36sp"
app:vcDividerWidth="8dp"
app:vcWrapper="centerLine"
app:vcWrapperColor="#313335"
app:vcNextWrapperColor="#b63b21"
app:vcWrapperStrokeWidth="2dp" />
  • java

verifycodeView.setOnAllFilledListener(newVerifyCodeView.OnAllFilledListener() {
@OverridepublicvoidonAllFilled(Stringtext) {
Toast.makeText(MainActivity.this, "filled by "+text, Toast.LENGTH_SHORT).show();
}
});
  • Customize Wrapper

verifycodeView.setVcWrapper(newVerifyCodeWrapper() {
@OverridepublicbooleanisCovered() {
//whether the wrapper and verify code display togetherreturnfalse;
}
@OverridepublicvoiddrawWrapper(Canvascanvas, Paintpaint, RectFrectF, RectFtextRectF) {
//draw your own wrappercanvas.drawLine(textRectF.left - textRectF.width()/2, rectF.height()/2, textRectF.right + textRectF.width() / 2, rectF.height()/2, paint);
}
});
  • Auto filled by SMS

SmsVerifyCodeFilterfilter = newSmsVerifyCodeFilter();
filter.setSmsSenderStart("1096");
filter.setSmsSenderContains("5225");
filter.setSmsBodyStart("验证短信:");
filter.setSmsBodyContains("验证码");
filter.setVerifyCodeCount(verifyCodeView.getVcTextCount());
verifyCodeView.startListen(filter);

About

VerifyCodeView is a android view for inputting Verification Code.

Resources

Stars

24 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages