android - Xamarin Forms 自定义键盘 Unicode 字符
问题描述
我正在尝试在 Xamarin Forms 应用程序中构建一个自定义键盘,该键盘使用 Unicode 符号而不是标准 ASCII 布局,但每当我按下键盘上的相应按钮时,这些符号不会显示在标准编辑器或条目组件中。
我的实现完全基于这个Github repo。如果我将此存储库中的原始布局 XML 文件更改为包含我所针对的 Unicode 字符之一,则该特定按钮将不会打印该符号:
<?xml version="1.0" encoding="UTF-8" ?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="8%p"
android:keyHeight="50dp"
android:horizontalGap="1%p"
android:verticalGap="1%p">
<Row android:keyHeight="4dp" android:rowEdgeFlags="top" android:verticalGap="1%p">
<Key android:codes="0" android:keyWidth="100%p" android:keyIcon="@drawable/kb_separator_line" />
</Row>
<Row>
<Key android:codes="0" android:keyWidth="0dp" android:horizontalGap="2%p" android:keyEdgeFlags="left" />
<Key android:codes="0x10D0" android:keyLabel="ა" android:keyWidth="18%p" />
<Key android:codes="30" android:keyLabel="B" android:keyWidth="18%p" />
<Key android:codes="31" android:keyLabel="C" android:keyWidth="18%p" />
<Key android:codes="32" android:keyLabel="D" android:keyWidth="18%p" />
<Key android:codes="33" android:keyLabel="E" android:keyWidth="18%p" />
<Key android:codes="0" android:keyWidth="0dp" android:horizontalGap="2%p" android:keyEdgeFlags="right" />
</Row>
<Row>
<Key android:codes="0" android:keyWidth="0dp" android:horizontalGap="2%p" android:keyEdgeFlags="left" />
<Key android:codes="8" android:keyLabel="1" android:keyWidth="18%p" />
<Key android:codes="9" android:keyLabel="2" android:keyWidth="18%p" />
<Key android:codes="10" android:keyLabel="3" android:keyWidth="18%p" />
<Key android:codes="11" android:keyLabel="4" android:keyWidth="18%p" />
<Key android:codes="12" android:keyLabel="5" android:keyWidth="18%p" />
<Key android:codes="0" android:keyWidth="0dp" android:horizontalGap="2%p" android:keyEdgeFlags="right" />
</Row>
<Row>
<Key android:codes="0" android:keyWidth="0dp" android:horizontalGap="2%p" android:keyEdgeFlags="left" />
<Key android:codes="13" android:keyLabel="6" android:keyWidth="18%p" />
<Key android:codes="14" android:keyLabel="7" android:keyWidth="18%p" />
<Key android:codes="15" android:keyLabel="8" android:keyWidth="18%p" />
<Key android:codes="16" android:keyLabel="9" android:keyWidth="18%p" />
<Key android:codes="7" android:keyLabel="0" android:keyWidth="18%p" />
<Key android:codes="0" android:keyWidth="0dp" android:horizontalGap="2%p" android:keyEdgeFlags="right" />
</Row>
<Row>
<Key android:codes="0" android:keyWidth="0dp" android:horizontalGap="2%p" android:keyEdgeFlags="left" />
<Key android:codes="67" android:keyLabel="DELETE" android:keyWidth="37%p" />
<Key android:codes="66" android:keyLabel="ENTER" android:keyWidth="56%p" />
<Key android:codes="0" android:keyWidth="0dp" android:horizontalGap="2%p" android:keyEdgeFlags="right" />
</Row>
</Keyboard>
请注意 <Key android:codes="0x10D0" android:keyLabel="ა" android:keyWidth="18%p" />
格鲁吉亚字母表中的字母“ა”所在的行,其 Unicode 值以十六进制表示。我已经尝试过 android:codes 的十进制值,以及 android:keyLabel 的 '\u' 格式,但无论我做什么,在 Android 上运行此应用程序时都不会显示该符号。
如果我以编程方式将此或任何其他格鲁吉亚符号插入到编辑器或条目中,它就会显示出来,所以我知道我的问题与我的特定 Android 版本或不支持这些符号的平板电脑无关。
我正在使用带有 Android 6.1 的联想 TB-X304L。这里可能是什么问题?
解决方案
我无法找到针对此特定问题的解决方案,因此我决定提供负索引值android:codes
,然后在覆盖的方法中检查这些值,OnKey()
并将相应的字符手动附加到条目/编辑器。
推荐阅读
- php - 如何在单个 PHP 文件中运行多个 SQL 调用过程
- laravel - 如何从数据透视表 Laravel(Laravel 8)打印一次性数据
- java - 我为 MYSQL 列使用什么数据类型将其连接到 Java 列表
? - c - 简单的 for 循环突然使 C 中的程序崩溃
- java - 为什么我的程序没有运行?我在 Eclipse IDE 中,它没有运行
- ruby - Ruby tty 提示多选字符串
- python - 如何使用pymupdf从较大的pdf中的选定页面中提取文本?
- php - 无法在 laravel 8.x 中使用 Handler.php 的渲染方法
- javascript - ReactJS 和 Javascript:尝试将 JSON 对象设置为状态挂钩时出现“错误:对象作为 React 子项无效”
- django - 如何从某些模型中删除 JWT 身份验证要求?Django Rest API / Axios