Coder Social home page Coder Social logo

vercodelayout's Introduction

VerCodeLayout

可能是支持属性最多的类似验证码的输入控件了。

引入依赖

implementation 'com.simple:VerCodeLayout:1.0.0'

基本使用

使用VerCodeEditText控件

<com.simple.vclayout.VerCodeEditText
    android:id="@+id/vcEt1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:vcCount="6"
    app:vcFocusedBackground="@drawable/sp_focused_one"
    app:vcMargin="5dp"
    app:vcNormalBackground="@drawable/sp_normal_one"
    app:vcTextSize="20sp" />

可用的属性

属性名 作用
vcCount EditText的个数
vcMaxLength EditText最大输入长度
vcNormalBackground 未选中的背景
vcFocusedBackground 选中的背景
vcWidth EditText的宽
vcHeight EditText的高
vcMinWidth EditText的最小宽度
vcMinHeight EditText的最小高度
vcMargin EditText的外边距,当然还有MarginLeft等小属性
vcPadding EditText的内边距,当然还有PaddingLeft等小属性
vcTextSize EditText的文本大小
vcTextColor EditText的文本颜色
vcTextCursorDrawable EditText的游标Drawable
vcGravity EditText的Gravity
vcInputType EditText的输入类型

高级使用

使用VerCodeLayout控件,VerCodeEditText继承于VerCodeLayout。VerCodeLayout自带了当一个EditText输入完成选中下一个或删除完成选中上一个的功能,但是EditText必须设置maxLength

<!--车牌-->
<com.simple.vclayout.VerCodeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:background="@drawable/sr_et_bg_accent"
        android:gravity="center"
        android:inputType="text"
        android:maxLength="1" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:background="@drawable/sr_et_bg_accent"
        android:gravity="center"
        android:inputType="text"
        android:maxLength="1" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:background="@drawable/sr_et_bg_accent"
        android:gravity="center"
        android:inputType="number"
        android:maxLength="1" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:background="@drawable/sr_et_bg_accent"
        android:gravity="center"
        android:inputType="number"
        android:maxLength="1" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:background="@drawable/sr_et_bg_accent"
        android:gravity="center"
        android:inputType="number"
        android:maxLength="1" />
</com.simple.vclayout.VerCodeLayout>

可用的方法

方法名 方法作用
setOnCompleteListener 监听输入完成
clear 清除所有的输入
getEditTexts 获取所有的EditText

版本更新

  • 1.0.0 首次上传

vercodelayout's People

Contributors

simplepeng avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.