国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

Android 使用fast-verification實現驗證碼填寫功能的實例代碼

瀏覽:4日期:2022-09-24 17:56:54

fast-verification

驗證碼的驗證環節現在是移動APP中不可缺少的一部分,直接使用EditText組件雖然方便但缺少了一些美感,使用fast-verification,讓實現驗證碼變得更簡單。

Android 使用fast-verification實現驗證碼填寫功能的實例代碼

依賴到項目項目根gradle中添加

maven { url ’https://www.jitpack.io’ }

示例:

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

在需要使用的module層級的gradle中添加

implementation ’com.github.sariki-L:fast-verification:1.1’

示例:

dependencies { ... implementation ’com.github.sariki-L:fast-verification:1.1’}

正式使用xml中添加VerificationLayout

<com.sariki.fastverification.VerificationLayout android:background='@android:color/transparent' android: android:layout_width='match_parent' android:layout_height='match_parent'/>

初始化

verification = findViewById(R.id.verification); verification.init(this, VerificationType.LENGTH_LONG);

變量名 對應驗證碼長度 VerificationType.LENGTH_LONG 6位 VerificationType.LENGTH_SHORT 4位

驗證碼輸入完成時的回調

verification.setEndListener(new VerificationTypeListener() { @Override public void onFinish(String result) { if (!result.equals(**需校對內容**)){ verification.setErrType(); }else{ ... } } });

在setEndListener中設置監聽,重寫onFinish方法處理輸入完成后的狀態。setErrType為調用默認錯誤處理。

設置參數

如果對默認驗證碼框背景不滿意,可以在代碼中對部分參數進行更改

需寫在init調用前

設置驗證碼框背景

verification.setDrawBackground();

設置驗證碼文字大小

verification.setDrawSize();

設置驗證碼文字顏色

verification.setDrawColor();

項目地址:github

總結

到此這篇關于Android 使用fast-verification實現驗證碼填寫功能的文章就介紹到這了,更多相關Android 使用fast-verification實現驗證碼填寫功能內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Android
相關文章:
主站蜘蛛池模板: 丹凤县| 海林市| 洛阳市| 宾阳县| 惠东县| 上杭县| 措美县| 遵义县| 高雄市| 高州市| 渝北区| 绿春县| 仲巴县| 蓝田县| 绥宁县| 新竹县| 东宁县| 晋城| 沭阳县| 固安县| 报价| 营口市| 翼城县| 瑞金市| 项城市| 张掖市| 台安县| 寿光市| 清水县| 乐东| 唐海县| 叙永县| 石林| 凭祥市| 万山特区| 阳西县| 清远市| 彭州市| 合水县| 陈巴尔虎旗| 图木舒克市|