LazyKeyboard
LazyKeyboard,利用PopupWindow实现,字母,符号,数字自定义安全键盘
使用
Gradle
Step 1. 项目根目录下 build.gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. 模块目录下build.gradle添加依赖
dependencies {
implementation 'com.github.onlyloveyd:LazyKeyboard:v1.1'
}
基本用法
Step 1. 添加 SecurityEditText 至界面布局。
<LinearLayout
android:id="@+id/container"
...">
<com.gs.keyboard.SecurityEditText
android:id="@+id/et_security_keyboard"
android:layout_width="match_parent"
... />
<EditText
android:id="@+id/et_security_keyboard_two"
... />
</LinearLayout>
Step 2. 初始化 SecurityKeyboard
//配置部分属性
SecurityConfigure configure = new SecurityConfigure()
.setDefaultKeyboardType(KeyboardType.NUMBER)
.setLetterEnabled(false);
//第一个参数为包含SecurityEditText的视图,安全键盘的显示以其为锚点
securityKeyboard = new SecurityKeyboard(binding.loginLayout, configure);
Step 2. 目前支持自定义选项
自定义选项 | 意义 |
---|---|
selectedColor | 选中键盘类型凸显颜色,默认为0xff66aeff |
unSelectedColor | 未选中键盘类型凸显颜色,默认为Color.BLACK |
isNumberEnabled | 是否显示数字键盘,默认为true |
isLetterEnabled | 是否显示字母键盘,默认为true |
isSymbolEnabled | 是否显示符号键盘,默认为true |
defaultKeyboardType | 默认选中的键盘,默认值为KeyboardType.LETTER |
基础效果