您的位置:首页 > 移动开发 > Android开发

android键盘

2016-06-12 16:57 337 查看
在应用的开发过程中有不少的情况下会用到自定义键盘,例如支付宝的支付密码的输入,以及类似的场景。android系统给开发者们提供了系统键盘,KeyboardView,其实并不复杂,只是有些开发者不知道罢了,在这里记录下,避免以后遗忘。

在布局文件中是这样写的:

<android.inputmethodservice.KeyboardView
android:id="@+id/jcd_keyboard_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:layout_marginTop="48dp"
android:keyBackground="@drawable/jcd_keybox_bg"
android:focusableInTouchMode="true"
android:shadowColor="#f2f2f2"
android:shadowRadius="0.0"
android:keyPreviewLayout="@layout/key_preview_layout"
android:background="#f2f2f2"
android:keyTextColor="#646464"
/>


keybackground是按键的背景图片最好是使用.9.png图片,这样会防止按键的背景拉伸变形,keyPreviewLayput是按键后的字母放大显示的界面

效果图片如下:


在项目的开发过程中,还会遇到一种自定义的键盘样式,就是数字是随机变化的

效果图如下:


最后希望有用到的园友们到我的github中去下载源码:
https://github.com/reachchen/Androidkeybox
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: