Skip to content

自定义验证码/密码输入框 custom code input view for android

License

Notifications You must be signed in to change notification settings

GalenLeo/CodeInputView

Repository files navigation

CodeInputView 自定义code输入框

Download API

Futures特性

  1. 支持纯数字/字母/自动大写/密码/纯数字密码 输入
  2. 支持自定义背景
  3. 支持使用自定义键盘
Demo效果图

Usage如何使用

Step 1

Gradle

implementation 'com.galenleo.widgets:code-input-view:1.0.0'

Step 2

<com.galenleo.widgets.CodeInputView
    android:id="@+id/verification_code_input_view"
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:layout_gravity="center_horizontal"
    android:layout_marginTop="24dp"
    app:ciItemWidth="40dp"
    app:ciTextSize="@dimen/txt_20"
    app:ciTextColor="@color/title_color"
    app:ciInputType="textCapCharacters"
    app:ciGapWidth="10dp"
    app:ciItemCount="6"
    app:ciItemBackground="@drawable/selector_code_input_item"/>

Step 3

Custom Drawable 自定义背景图片

selector_code_input_item.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true">
        <shape>
            <solid android:color="#42362F"/>
            <corners android:radius="4dp"/>
        </shape>
    </item>
    <item>
        <shape>
            <solid android:color="#2D2D35"/>
            <corners android:radius="4dp"/>
        </shape>
    </item>
</selector>

Attributes属性

attr default description
ciItemCount 4 code item count
ciItemWidth code item width
ciGapWidth 10px gap between item
ciTextSize 24px code text size
ciTextColor Color.CYAN code text color
ciInputType text number(数字)
text(字母/数字)
textCapCharacters(大写字母/数字)
password(密码)
numberPassword(数字密码)
ciItemBackground code item background
ciSoftInputEnable true enable to show the soft keyboard
是否显示软键盘,使用自定义键盘的时候关闭

About

自定义验证码/密码输入框 custom code input view for android

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages