繁体   English   中英

在 Android 键盘中添加子菜单?

[英]Add a submenu in an Android Keyboard?

我正在尝试创建一个自定义 Android 键盘,只是想学习这个过程。 在此处输入图像描述

我一直比较成功,因为我现在只是在学习基础知识:

在此处输入图像描述

我的问题是,我怎样才能从我按住一个键并弹出更多选项列表的常用键盘实现这种效果?

在此处输入图像描述

任何帮助表示赞赏。

只是对于将来可能需要这个的人,主要的方法是使用 xml 键盘:

<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
    android:keyWidth="10%p"
    android:horizontalGap="4px"
    android:verticalGap="4px"
    android:keyHeight="45dp">

    <Row>
        <Key android:keyLabel="q" android:popupKeyboard="@xml/qwerty_q" android:keyEdgeFlags="left"/>
        <Key android:keyLabel="w" android:popupKeyboard="@xml/qwerty_w"/>
        <Key android:keyLabel="e" android:popupKeyboard="@xml/qwerty_e"/>
        <Key android:keyLabel="r" android:popupKeyboard="@xml/qwerty_r"/>
        <Key android:keyLabel="t" android:popupKeyboard="@xml/qwerty_t"/>
        <Key android:keyLabel="y" android:popupKeyboard="@xml/qwerty_y"/>
        <Key android:keyLabel="u" android:popupKeyboard="@xml/qwerty_u"/>
        <Key android:keyLabel="i" android:popupKeyboard="@xml/qwerty_i"/>
        <Key android:keyLabel="o" android:popupKeyboard="@xml/qwerty_o"/>
        <Key android:keyLabel="p" android:popupKeyboard="@xml/qwerty_p"/>
    </Row>
</Keyboard>

然后在“xml”文件夹下创建每个相关的键盘,格式为 xml:

在此处输入图像描述

在弹出式键盘中进行格式化:

<?xml version="1.0" encoding="utf-8"?>

<Keyboard
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:keyWidth="10%p"
    android:horizontalGap="4px"
    android:verticalGap="4px"
    android:keyHeight="40dp">

    <Row android:gravity="center_horizontal">
        <Key android:keyLabel="s" android:keyEdgeFlags="left"/>
        <Key android:keyLabel="ſ"/>
        <Key android:keyLabel="ƨ"/>
        <Key android:keyLabel="ß"/>
        <Key android:keyLabel="σ"/>
        <Key android:keyLabel="ς"/>
    </Row>
</Keyboard>

还有一个选项可以添加弹出字符,但我不确定它是否支持输入完整的字符串,如果需要输入“.com”、“.net”、&c,您可能想要这样。

<?xml version="1.0" encoding="utf-8"?>

<Keyboard
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:keyWidth="10%p"
    android:horizontalGap="4px"
    android:verticalGap="4px"
    android:keyHeight="40dp">

    <Row android:gravity="center_horizontal">
        <Key android:keyLabel=".com" android:keyOutputText=".com">
        <Key android:keyLabel=".net" android:keyOutputText=".net">
        <Key android:keyLabel=".jpg" android:keyOutputText=".jpg">
        <Key android:keyLabel="·e·" android:keyOutputText="·e·"/>
    </Row>
</Keyboard>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM