java - 创建支持越南语和英语的自定义键盘 android

标签 java android custom-keyboard soft-keyboard

我计划在 Android 上创建一个自定义软键盘,支持英语和越南语两种语言。我在互联网上搜索了在 Android 上创建自定义键盘的指南:https://developer.android.com/guide/topics/text/creating-input-method.html 。 但我仍然不知道如何创建越南语键盘。在越南语键盘中,我需要处理一些情况: - 有些键当我双击时,它会变成另一个键。示例:

A -> double press: Â
O -> double press: Ô
E -> double press: Ê
... 
  • 有些键当我组合在一起按下时,它就变成了新的键。示例:

    按 A,然后快速按 W -> 变成 Ă。 按 O,然后快速按 W -> 变成Ơ。 按 H、O、T、S -> 变为 HÓT。 按 H、O、N、F -> 变为 HÒN。 按 H、O、T、J -> 变成 HỌT。 按 H、O、I、R -> 变成 HỎI。 按 N、G、A、X -> 变为 NGà...

如何为越南语键盘创建keyboard_layout.xml?在上述情况下,如何在 android java 代码中处理越南语键盘?

最佳答案

这是您使用 IME 可以做到的唯一方法。请参阅http://developer.android.com/guide/topics/text/creating-input-method.html

<input-method xmlns:android="http://schemas.android.com/apk/res/android"
    android:settingsActivity="com.android.inputmethod.latin.SettingsActivity"
    android:isDefault="@bool/im_is_default">
<subtype android:icon="@drawable/ic_subtype_keyboard"
        android:label="@string/subtype_en_US"
        android:imeSubtypeLocale="en_US"
        android:imeSubtypeMode="keyboard"
      android:imeSubtypeExtraValue="TrySuppressingImeSwitcher,AsciiCapable,SupportTouchPositionCorrection"
/>

  <subtype android:icon="@drawable/ic_subtype_keyboard"
        android:label="@string/subtype_generic"
        android:imeSubtypeLocale="vi"
        android:imeSubtypeMode="keyboard"
        android:imeSubtypeExtraValue="KeyboardLayoutSet=qwerty,AsciiCapable"
/>

关于java - 创建支持越南语和英语的自定义键盘 android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59551536/

相关文章:

java - 如果我的组件的 PreferredSize 高于 Integer.MAX_VALUE 怎么办?

java - 在访问器(getter)方法上使用转换器时出现异常

ios8 - 如何检测 iOS 8 中自定义键盘扩展的方向变化?

android - ImageView 作为单元格中的背景

android - 包含协程延迟时如何对协程进行单元测试?

android - 是否可以在 flutter 中开发移动键盘应用程序

ios - 如何从 iOS 8 中的应用程序打开常规设置(不在应用程序设置中)?

java - 为什么我得到的是 null 而不是 Map 对象?如何解决这个问题?

java - log4j 性能

java - 使用带有 BLOB 数据的游标加载器