第一步

android {

compileOptions{    sourceCompatibility JavaVersion.VERSION_1_8    targetCompatibility JavaVersion.VERSION_1_8}

dependencies {

    implementation 'com.github.Wynsbin:VerificationCodeInputView:1.0.2'

     }

}

 

allprojects {

    repositories {

        maven { url 'https://jitpack.io' }

      }

}

 

第二步

    android:id="@+id/vciv_code"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="48dp"
    android:gravity="center"
    android:orientation="horizontal"
    app:vciv_et_background="@android:color/white"
    app:vciv_et_foucs_background="@android:color/holo_orange_dark"
    app:vciv_et_cursor_color="@color/colorPrimary"
    app:vciv_et_height="58dp"
    app:vciv_et_inputType="number"
    app:vciv_et_number="6"
    app:vciv_et_text_color="@android:color/black"
    app:vciv_et_text_size="18sp"
    app:vciv_et_underline_default_color="@android:color/holo_green_dark"
    app:vciv_et_underline_focus_color="@android:color/holo_blue_bright"
    app:vciv_et_underline_height="2dp"
    app:vciv_et_underline_show="true"
    app:vciv_et_width="58dp" />

 

第三步

VerificationCodeInputView view = findViewById(R.id.vciv_code);
view.setOnInputListener(new VerificationCodeInputView.OnInputListener() {
    @Override
    public void onComplete(String code) {
        Toast.makeText(MainActivity.this, code, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onInput() {

    }
});

//清除验证码
view.clearCode();
 

详情参考:https://blog.csdn.net/qq_30552993/article/details/102582641

更多相关文章

  1. JNI 无法确定Bitmap的签名
  2. android studio 生成 release aar
  3. 参考注释郭霖老师的Android相机程序
  4. 【Android平台】 Alljoyn学习笔记四 Android(安卓)Core API参考
  5. Android的ListView,数据更新后自动scroll到底部。
  6. Android非UI线程访问UI线程的方法总结
  7. Windows下Eclipse 安装 android maven插件教程
  8. 2011.06.03(2)——— android 1.6 launcher研究之自定义ViewGroup
  9. 2011.06.03(2)——— android 1.6 launcher研究之自定义ViewGroup

随机推荐

  1. Android之音量调节
  2. Android(安卓)studio导入Android(安卓)st
  3. Android技术栈
  4. Android(安卓)in Practice笔记第二章
  5. Android(安卓)连接tomcat模拟登陆账号
  6. 设置Android(安卓)app背景图片(Android(
  7. android listview 上下边缘的模糊去掉
  8. 收集android的三个小tip
  9. Android中VectorDrawableCompat的使用注
  10. 自动启动程序