Square verification code input box VerificationCodeView

Contact : QQ 839539179 WEIXIN tuojie003    

VerificationCodeView —square verification code input box


Example:Animation demonstration Animation demonstration

apk demo: click to download


characteristic

Custom properties

name illustrate format default value
icv_et_number Number of input boxes integer 1
icv_et_width The width of the input box dimension 42dp
icv_et_divider_drawable spacing between input boxes reference  
icv_et_text_color Input box text color color Color.WHITE
icv_et_text_size Input box text size dimension 16sp
icv_et_bg_focus Border when input box gets focus reference  
icv_et_bg_normal Border when input box has no focus reference  
icv_et_pwd Whether it is password mode boolean false
icv_et_pwd_radius The radius of the circle in password mode dimension reference

Available methods

method_name description return_type
getInputContent Get input content String
clearInputContent Clear input content Void
setEtNumber(int etNumber) Set the number of input boxes Void
getEtNumber Get the number of input boxes int
getEditText Get the EditText provided to the outside world to set the keyboard popup EditText
setPwdMode Dynamically set whether it is password mode void
setInputCompleteListener(InputCompleteListener listener) Set up input and deletion monitoring Void

Principle description

This project is a combined control-type custom View inherited from RelativeLayout. A transparent EditText is used in the layout file to accept user input events. A square input box is dynamically added to the LinearLayout of the layout file. The square input box is actually They are TextViews one by one.


Instructions

1 Gradle reference

implementation 'com.jacktuotuo.customview:verificationcodeview:1.0.5'

2 used in xml

  • Simple configuration
<com.tuo.customview.VerificationCodeView
        android:id="@+id/icv_1"
        app:icv_et_number="5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
  • Personalized configuration
    <com.tuo.customview.VerificationCodeView
          android:id="@+id/icv"
          android:layout_width="match_parent"
          android:layout_height="50dp"
          android:layout_centerHorizontal="true"
          android:layout_marginLeft="10dp"
          android:layout_marginRight="10dp"
          android:layout_marginTop="26dp"
          app:icv_et_bg_focus="@drawable/shape_icv_et_bg_focus"
          app:icv_et_bg_normal="@drawable/shape_icv_et_bg_normal"
          app:icv_et_divider_drawable="@drawable/shape_divider_identifying"
          app:icv_et_number="6"
          app:icv_et_pwd="true"
          app:icv_et_pwd_radius="10dp"
          app:icv_et_text_color="#000000"
          app:icv_et_width="50dp" />
    

3 used in java code

VerificationCodeView codeView = new VerificationCodeView(context);
codeView.setEtNumber(number);
codeVidw.setPwdMode(true/false)

Source code download  GitHub address

Guess you like

Origin blog.csdn.net/qq_28845393/article/details/109180584