当前位置:网站首页>直播系统代码,自定义软键盘样式:字母、数字、标点三种切换
直播系统代码,自定义软键盘样式:字母、数字、标点三种切换
2022-07-06 00:51:00 【云豹网络科技】
直播系统代码,自定义软键盘样式:字母、数字、标点三种切换
在需要的调用软键盘的activity_mian.xml中加入键盘控件
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<android.inputmethodservice.KeyboardView
android:id="@+id/keyboard_view"
android:shadowRadius="0.0"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:keyPreviewLayout="@layout/key_preview_layout"
android:background="#D6D9DE"
android:keyBackground="@drawable/btn_keyboard_key"
android:keyTextColor="#747474"
android:keyTextSize="36dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="95dp"
android:paddingRight="95dp"
android:visibility="gone"
/>
</RelativeLayout>
1.1
android:keyPreviewLayout="@layout/key_preview_layout"这个是长按键盘时弹出框的样式,如果不写,系统默认,默认的有时会会看不清
key_preview_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40sp"
android:textColor="@android:color/white"
android:gravity="center"
android:background="#80929299"/>
1.2
android:keyBackground="@drawable/btn_keyboard_key"按键的形状
btn_keyboard_key.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFFFF"/>
<corners android:topLeftRadius="8dip"
android:topRightRadius="8dip"
android:bottomRightRadius="8dip"
android:bottomLeftRadius="8dip" />
</shape>
2.然后在res文件夹下新建文件夹,里面新建三个文件,即每种键盘样式的布局分别为qwerty.xml, symbols.xml, punctuate.xml
字母键盘-qwerty.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Keyboard android:keyWidth="100dp" android:keyHeight="60dp"
android:horizontalGap="10dp" android:verticalGap="15dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<Row>
<Key android:codes="113" android:keyEdgeFlags="left"
android:keyLabel="q" />
<Key android:codes="119" android:keyLabel="w" />
<Key android:codes="101" android:keyLabel="e" />
<Key android:codes="114" android:keyLabel="r" />
<Key android:codes="116" android:keyLabel="t" />
<Key android:codes="121" android:keyLabel="y" />
<Key android:codes="117" android:keyLabel="u" />
<Key android:codes="105" android:keyLabel="i" />
<Key android:codes="111" android:keyLabel="o" />
<Key android:codes="112" android:keyEdgeFlags="right"
android:keyLabel="p" />
</Row>
<Row>
<Key android:horizontalGap="4.999995%p" android:codes="97"
android:keyEdgeFlags="left" android:keyLabel="a" />
<Key android:codes="115" android:keyLabel="s" />
<Key android:codes="100" android:keyLabel="d" />
<Key android:codes="102" android:keyLabel="f" />
<Key android:codes="103" android:keyLabel="g" />
<Key android:codes="104" android:keyLabel="h" />
<Key android:codes="106" android:keyLabel="j" />
<Key android:codes="107" android:keyLabel="k" />
<Key android:codes="108" android:keyEdgeFlags="right"
android:keyLabel="l" />
</Row>
<Row>
<Key android:keyWidth="110dp" android:codes="-1"
android:keyEdgeFlags="left" android:isModifier="true"
android:horizontalGap="33dp"
android:isSticky="true" android:keyIcon="@drawable/shift" />
<Key android:codes="122" android:keyLabel="z" android:horizontalGap="30dp"/>
<Key android:codes="120" android:keyLabel="x" />
<Key android:codes="99" android:keyLabel="c" />
<Key android:codes="118" android:keyLabel="v" />
<Key android:codes="98" android:keyLabel="b" />
<Key android:codes="110" android:keyLabel="n" />
<Key android:codes="109" android:keyLabel="m" />
<Key android:keyWidth="110dp" android:codes="-5"
android:horizontalGap="30dp"
android:keyEdgeFlags="right" android:isRepeatable="true"
android:keyIcon="@drawable/delete" />
</Row>
<Row android:rowEdgeFlags="bottom">
<Key android:keyWidth="110dp" android:codes="-2" android:horizontalGap="43dp"
android:keyIcon="@drawable/number" />
<Key android:keyWidth="110dp" android:codes="46"
android:keyIcon="@drawable/point" />
<Key android:keyWidth="540dp" android:codes="32"
android:isRepeatable="true" android:keyIcon="@drawable/space" />
<Key android:keyWidth="110dp" android:codes="47"
android:keyIcon="@drawable/gang"/>
<Key android:keyWidth="110dp" android:codes="-3"
android:keyEdgeFlags="right" android:keyIcon="@drawable/complete" />
</Row>
</Keyboard>
以上就是直播系统代码,自定义软键盘样式:字母、数字、标点三种切换, 更多内容欢迎关注之后的文章
边栏推荐
- devkit入门
- curlpost-php
- Leetcode 44 Wildcard matching (2022.02.13)
- Synchronized and reentrantlock
- Why can't mathematics give machine consciousness
- 测试/开发程序员的成长路线,全局思考问题的问题......
- 关于#数据库#的问题:(5)查询库存表中每本书的条码、位置和借阅的读者编号
- 毕设-基于SSM高校学生社团管理系统
- Programmer growth Chapter 9: precautions in real projects
- anconda下载+添加清华+tensorflow 安装+No module named ‘tensorflow‘+KernelRestarter: restart failed,内核重启失败
猜你喜欢
Meta AI西雅图研究负责人Luke Zettlemoyer | 万亿参数后,大模型会持续增长吗?
[groovy] JSON serialization (jsonbuilder builder | generates JSON string with root node name | generates JSON string without root node name)
Common API classes and exception systems
What is the most suitable book for programmers to engage in open source?
KDD 2022 | 脑电AI助力癫痫疾病诊断
cf:D. Insert a Progression【关于数组中的插入 + 绝对值的性质 + 贪心一头一尾最值】
如何制作自己的機器人
Model analysis of establishment time and holding time
免费的聊天机器人API
Ffmpeg captures RTSP images for image analysis
随机推荐
Questions about database: (5) query the barcode, location and reader number of each book in the inventory table
curlpost-php
C language programming (Chapter 6 functions)
程序员搞开源,读什么书最合适?
Promise
Promise
Browser reflow and redraw
Power query data format conversion, Split Merge extraction, delete duplicates, delete errors, transpose and reverse, perspective and reverse perspective
孤勇者
cf:H. Maximal AND【位运算练习 + k次操作 + 最大And】
毕设-基于SSM高校学生社团管理系统
VSphere implements virtual machine migration
MySQL storage engine
RAID disk redundancy queue
After Luke zettlemoyer, head of meta AI Seattle research | trillion parameters, will the large model continue to grow?
Yolov5、Pycharm、Anaconda环境安装
NLP generation model 2017: Why are those in transformer
[simple implementation of file IO]
《强化学习周刊》第52期:Depth-CUPRL、DistSPECTRL & Double Deep Q-Network
Intensive learning weekly, issue 52: depth cuprl, distspectrl & double deep q-network