2 Star 21 Fork 12

Jenly / SplitEditText

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

SplitEditText

Download JCenter MavenCentral JitPack CI CircleCI API License Blog QQGroup

SplitEditText for Android 是一个灵活的分割编辑框。常常应用于 验证码输入密码输入 、等场景。

特性说明

  • 支持设置框数量
  • 支持设置框的风格样式
  • 支持根据状态区分框颜色
  • 基于EditText实现,更优雅

Gif 展示

Image

SplitEditText 自定义属性说明

属性 值类型 默认值 说明
setStrokeWidth dimension 1dp 画笔描边的宽度
setBorderColor color #FF666666 边框颜色
setInputBorderColor color #FF1E90FF 已输入文本的边框颜色
setFocusBorderColor color 焦点框的边框颜色
setBoxBackgroundColor color 框的背景颜色
setBorderCornerRadius dimension 0dp 框的圆角大小(当 BorderSpacing0dp 时,只有最左和最右两端的框有圆角)
setBorderSpacing dimension 8dp 框与框之间的间距大小
setMaxLength integer 6 允许输入的最大长度(框个数量)
setBorderStyle enum box 边框风格
setTextStyle enum plain_text 文本风格(可以是明文或者密文,默认:明文)
setCipherMask string * 密文掩码(当 TextStyle 为密文时,可自定义密文掩码)
setFakeBoldText boolean false 是否是粗体

引入

  1. 在Project的 build.gradle 里面添加远程仓库
allprojects {
    repositories {
        //...
        mavenCentral()
    }
}
  1. 在Module的 build.gradle 里面添加引入依赖项
// AndroidX 版本
implementation 'com.github.jenly1314:splitedittext:1.1.0'

示例

布局示例

    <com.king.view.splitedittext.SplitEditText
        android:id="@+id/splitEditText"
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:inputType="number"/>

代码示例

Kotlin

    //设置监听
    splitEditText.setOnTextInputListener(object : SplitEditText.OnTextInputListener {
        override fun onTextInputChanged(text: String, length: Int) {
            //TODO 文本输入改变
        }

        override fun onTextInputCompleted(text: String) {
            //TODO 文本输入完成
        }

    })

Java

    //设置监听
    splitEditText.setOnTextInputListener(new SplitEditText.OnTextInputListener(){

        @Override
        public void onTextInputChanged(String text, int length) {
            //TODO 文本输入改变
        }

        @Override
        public void onTextInputCompleted(String text) {
            //TODO 文本输入完成
        }
    });

更多使用详情,请查看app中的源码使用示例

相关推荐

CodeTextField 一个使用 Compose 实现的验证码输入框

KingKeyboard 自定义键盘,满足各种不同场景的键盘输入需求

版本记录

v1.1.0:2023-1-9 (开始发布至MavenCentral)

  • 迁移发布至MavenCentral

v1.0.0:2021-1-5

  • SplitEditText初始版本

赞赏

如果您喜欢SplitEditText,或感觉SplitEditText帮助到了您,可以点右上角“Star”支持一下,您的支持就是我的动力,谢谢 :smiley:

您也可以扫描下面的二维码,请作者喝杯咖啡 :coffee:

关于我

Name: Jenly

Email: jenly1314#gmail.com / jenly1314#vip.qq.com

CSDN: jenly121

CNBlogs: jenly

GitHub: jenly1314

Gitee: jenly1314

加入QQ群: 20867961

The MIT License (MIT) Copyright (c) 2020 Jenly Yu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

SplitEditText 是一个灵活的分割编辑框。常常应用于验证码输入 、密码输入等场景。 展开 收起
Android 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Android
1
https://gitee.com/jenly1314/SplitEditText.git
git@gitee.com:jenly1314/SplitEditText.git
jenly1314
SplitEditText
SplitEditText
master

搜索帮助