简介
今天在掘金上看了一篇文章,实现自定义软键盘,发现其实实现方式比较简单,不需要改动系统api,只是单纯的加载自己的键盘布局,隐藏系统弹出的键盘,实现数字错位,安全输入软键盘,记录一下实现过程用于总结
github地址: https://github.com/fushuangdage/CustomView
实现
<?xml version="1.0" encoding="utf-8"?>
<Keyboard
xmlns:android="http://schemas.android.com/apk/res/android"
android:horizontalGap="0px"
android:keyHeight="9%p"
android:keyWidth="25%p"
android:verticalGap="0px"
>
<Row>
<Key
android:codes="49"
android:keyLabel="1"/>
<Key
android:codes="50"
android:keyLabel="2"/>
<Key
android:codes="51"
android:keyLabel="3"/>
<Key
android:codes="-5"
android:isRepeatable="true"
android:keyEdgeFlags="right"
android:keyHeight="18%p"
android:keyIcon="@drawable/icon_delete_32dp"/>
</Row>
<Row>
<Key
android:codes="52"
android:keyLabel="4"/>
<Key
android:codes="53"
android:keyLabel="5"/>
<Key
android:codes="54"
android:keyLabel="6"/>
</Row>
<Row>
<Key
android:codes="55"
android:keyLabel="7"/>
<Key
android:codes="56"
android:keyLabel="8"/>
<Key
android:codes="57"
android:keyLabel="9"/>
<Key
android:codes="-4"
android:keyEdgeFlags="right"
android:keyHeight="18%p"
android:keyLabel="确定"
android:keyIcon="@drawable/icon_enter_32dp"/>
</Row>
<