项目作者: jakode2020

项目描述 :
Verify Code Edit Text
高级语言: Kotlin
项目地址: git://github.com/jakode2020/VerifyCodeEditText.git
创建时间: 2021-02-18T09:41:21Z
项目社区:https://github.com/jakode2020/VerifyCodeEditText

开源协议:Apache License 2.0

下载


VerifyCodeEditText

Release
Kotlin Version
API

The use of verify code edit text is to get a one-time code from the user,
There is no default edit text in Android to get a one-time use code.

That’s why I decided to build a library so that both xml and kotlin could create such input :)

alt text

Gradle Setup


  1. repositories {
  2. maven { url 'https://jitpack.io' }
  3. }
  4. dependencies {
  5. implementation 'com.github.jakode2020:VerifyCodeEditText:1.2.0'
  6. }

Usage

XML

  1. <com.jakode.verifycodeedittext.VerifyCodeEditText
  2. android:layout_width="wrap_content"
  3. android:layout_height="wrap_content"
  4. android:layoutDirection="ltr" (RTL language need this field)
  5. android:paddingBottom="12dp"
  6. app:BottomErrorIcon="@drawable/bottom_error_icon"
  7. app:BottomIconHeight="2dp"
  8. app:BottomIconWidth="40dp"
  9. app:BottomSelectedIcon="@drawable/bottom_selected_icon"
  10. app:BottomUnSelectedIcon="@drawable/bottom_unselected_icon"
  11. app:ItemSpaceSize="28dp"
  12. app:TextColor="@color/black"
  13. app:TextFont="@font/baloo"
  14. app:TextSize="16sp"
  15. app:ViewCount="Four"></com.jakode.verifycodeedittext.VerifyCodeEditText>

complete listener

  1. verifyCodeEditText.setCompleteListener { complete ->
  2. // some code
  3. }

change bottom drawable state

  1. // all bottom drawble show erro state
  2. verifyCodeEditText.setCodeItemErrorLineDrawable()
  3. // reset drawble to normal state
  4. verifyCodeEditText.resetCodeItemLineDrawable()

alt text

set / get text

  1. verifyCodeEditText.text = "99999" // set
  2. println(verifyCodeEditText.text) // get

Kotlin Builder

  1. val verifyCodeEditText = VerifyCodeEditText.Builder {
  2. text {
  3. size = 20F
  4. color = Color.parseColor("#000000")
  5. }
  6. bottomIcon {
  7. iconHeight = 5
  8. iconWidth = 60
  9. selectedIcon = ContextCompat.getDrawable(this@MainActivity, R.drawable.bottom_selected_icon)
  10. unSelectedIcon = ContextCompat.getDrawable(this@MainActivity, R.drawable.bottom_unselected_icon)
  11. errorIcon = ContextCompat.getDrawable(this@MainActivity, R.drawable.bottom_error_icon)
  12. }
  13. verifyCell {
  14. count = VerifyCodeEditText.Builder.ViewCount.Five
  15. spaceSize = 48
  16. }
  17. }.build(context = this)
  18. findViewById<ConstraintLayout>(R.id.layout).addView(verifyCodeEditText)

License


  1. Copyright 2021 Jakode2020
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.