【Android自定义View】车牌号输入法

VehicleEditText

Android用于车牌号输入的自定义键盘.仿"支付宝-车主服务-添加车辆-车牌号"输入框展示的车牌号输入键盘。以下是本作与支付宝的对比图:
对比图

一、效果展示

效果展示

二、如何使用

app/build.gradledependencies节点下添加:

implementation "wang.relish.vehicleedittext:vehicleedittext:0.0.1-SNAPSHOT"

在根目录的build.gradle中添加:

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://oss.sonatype.org/content/groups/public" } // 添加这行
    }
}

然后Sync Now就行啦.

1 使用wang.relish.vehicleedittext.VehicleEditText

和正常的EditText一样使用即可。
不过需要注意VehicleEditText设置了以下监听器:

  • View.OnTouchListener
  • View.OnFocusChangeListener
  • View.OnKeyListener

如果你也需要设置这些监听器,需要注意确保不要覆盖这些监听器的功能。而是使用VehicleEditText的setOnTouchListener2/setOnFocusChangeListener2/setOnKeyListener2等方法设置监听器。

<wang.relish.vehicleedittext.VehicleEditText
    android:id="@+id/vet"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

2 使用原生EditText

如果你不需要设置上述的监听器,你可以使用下面这种侵入性更小的方法。

EditText vehicleEditText = findViewById(R.id.vet);
VehicleKeyboardHelper.bind(vehicleEditText); // 为输入框绑定车牌号输入键盘

三、混淆配置

四、最后

项目地址: https://github.com/relish-wang/VehicleEditText
欢迎star~

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值