最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android 自定義驗(yàn)證碼輸入框的實(shí)例代碼(支持粘貼連續(xù)性)

 更新時(shí)間:2019年10月18日 08:36:26   作者:騷劍客  
這篇文章主要介紹了Android 自定義驗(yàn)證碼輸入框的實(shí)例代碼(支持粘貼連續(xù)性),代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

需求

1、能自定義輸入框個(gè)數(shù)和樣式

2、支持長(zhǎng)按粘貼或剪切板內(nèi)容自動(dòng)填充(粘貼連續(xù)性)

其中第2點(diǎn)是最為重要的,正是其他人沒(méi)有這點(diǎn),逼得自己弄一個(gè)

示例

別人的示例:

在這里插入圖片描述

粘貼居然不支持連續(xù)性,只能粘貼第一個(gè)字符,所以用的有點(diǎn)難受

自己的示例:

在這里插入圖片描述

原理

大致是Edittext + n* TextView,然后設(shè)置edittext字體跟背景顏色都為透明,隱藏光標(biāo)

Edittext:監(jiān)聽(tīng)edittext每次輸入一個(gè)字符就賦值到對(duì)應(yīng)的TextView上,然后在清空自己

下劃線(xiàn):在TextView下面添加View

光標(biāo):這里的每個(gè)TextView的焦點(diǎn)光標(biāo)其實(shí)對(duì)View設(shè)置了ValueAnimator

粘貼:粘貼彈窗是自定義的PopupWindow

源碼有詳細(xì)注釋?zhuān)@里就不一一說(shuō)明

Github

https://github.com/WShaobin/VerificationCodeInputView

Gradle

Step 1. Add it in your root build.gradle at the end of repositories:

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

Step 2. Add the dependency:

dependencies {
  implementation 'com.github.WShaobin:VerificationCodeInputView:1.0.2'
}

How to use

In layout

<com.wynsbin.vciv.VerificationCodeInputView
  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" />

In Java Code

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() {

  }
});

//清除驗(yàn)證碼
view.clearCode();

Attributes

VCInputType

 

 輸入框背景色支持類(lèi)型

1、@drawable/xxx

2、@color/xxx

3、#xxxxxx

總結(jié)

以上所述是小編給大家介紹的Android 自定義驗(yàn)證碼輸入框的實(shí)例代碼(支持粘貼連續(xù)性),希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺(jué)得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!

相關(guān)文章

  • 詳解Android跨進(jìn)程通信之AIDL

    詳解Android跨進(jìn)程通信之AIDL

    這篇文章主要介紹了詳解Android跨進(jìn)程通信之AIDL,想了解跨進(jìn)程的同學(xué)可以參考下
    2021-04-04
  • Android sqlite cursor的遍歷實(shí)例詳解

    Android sqlite cursor的遍歷實(shí)例詳解

    在本篇內(nèi)容里小編給大家整理的是一篇關(guān)于A(yíng)ndroid sqlite cursor的遍歷的相關(guān)實(shí)例及知識(shí)點(diǎn),需要的朋友們可以學(xué)習(xí)下。
    2021-06-06
  • Android BottomNavigationView結(jié)合ViewPager實(shí)現(xiàn)底部導(dǎo)航欄步驟詳解

    Android BottomNavigationView結(jié)合ViewPager實(shí)現(xiàn)底部導(dǎo)航欄步驟詳解

    這篇文章主要介紹了Android BottomNavigationView結(jié)合ViewPager實(shí)現(xiàn)底部導(dǎo)航欄步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧
    2023-02-02
  • 最新評(píng)論

    宜阳县| 嫩江县| 九江县| 荆州市| 汕头市| 郁南县| 扶沟县| 堆龙德庆县| 定日县| 谷城县| 三都| 什邡市| 怀化市| 汽车| 鹤山市| 安新县| 常州市| 湘潭市| 永德县| 朝阳区| 泽州县| 宜君县| 花莲市| 冀州市| 庆城县| 丰台区| 新密市| 保定市| 格尔木市| 安徽省| 包头市| 万州区| 大关县| 江山市| 平利县| 义马市| 奉化市| 西林县| 沁阳市| 昌平区| 阜平县|