首页 > 解决方案 > 自定义键盘 - 错误的数字输入

问题描述

我为我的三星 S8 制作了一个自定义键盘。keyboard.xml 文件如下所示:

<?xml version="1.0" encoding="utf-8"?>
<Keyboard n1:keyWidth="13.999998%p" n1:keyHeight="40.0dip" n1:horizontalGap="2.6000023%p" n1:verticalGap="10.0dip"
  xmlns:n1="http://schemas.android.com/apk/res/android">
    <Row n1:keyHeight="0.100000024px" n1:rowEdgeFlags="top" />
    <Row>
        <Key n1:keyWidth="8.7%p" n1:horizontalGap="1.05%p" n1:codes="49" n1:keyEdgeFlags="left" n1:keyLabel="1" />
        <Key n1:keyWidth="8.7%p" n1:horizontalGap="1.05%p" n1:codes="50" n1:keyLabel="2" />
        <Key n1:keyWidth="8.7%p" n1:horizontalGap="1.05%p" n1:codes="51" n1:keyLabel="3" />
        <Key n1:keyWidth="8.7%p" n1:horizontalGap="1.05%p" n1:codes="52" n1:keyLabel="4" />
        <Key n1:keyWidth="8.7%p" n1:horizontalGap="1.05%p" n1:codes="53" n1:keyLabel="5" />
        <Key n1:keyWidth="8.7%p" n1:horizontalGap="1.05%p" n1:codes="54" n1:keyLabel="6" />
        <Key n1:keyWidth="8.7%p" n1:horizontalGap="1.05%p" n1:codes="55" n1:keyLabel="7" />
        <Key n1:keyWidth="8.7%p" n1:horizontalGap="1.05%p" n1:codes="56" n1:keyLabel="8" />
        <Key n1:keyWidth="8.7%p" n1:horizontalGap="1.05%p" n1:codes="57" n1:keyLabel="9" />
        <Key n1:keyWidth="8.7%p" n1:horizontalGap="1.05%p" n1:codes="48" n1:keyLabel="0" />
    </Row>
</Keyboard>

(我省略了其他行,只有第一行包含在代码中)。

当我点击键盘数字时,我得到的不是写“1”、“2”等,而是用 ASCII 圈起来的数字,例如“❶”、“❷”等。怎么会这样?ASCII 代码是正确的(48、49 等)。

当然,这个错误只发生在自定义键盘上,而不是三星 S8 默认键盘。

我该如何解决这个问题?

标签: androidxmlkeyboardascii

解决方案


推荐阅读