简体   繁体   English

在 Android 键盘中添加子菜单?

[英]Add a submenu in an Android Keyboard?

I'm trying to create a custom Android Keyboard, just trying to learn the process.我正在尝试创建一个自定义 Android 键盘,只是想学习这个过程。 在此处输入图像描述

I've been relatively successful, as I'm just learning the basics for now:我一直比较成功,因为我现在只是在学习基础知识:

在此处输入图像描述

My question is, how can I achieve this effect from the usual keyboard in which I keep a key pressed and a list of more options will pop up?我的问题是,我怎样才能从我按住一个键并弹出更多选项列表的常用键盘实现这种效果?

在此处输入图像描述

Any help is appreciated.任何帮助表示赞赏。

Just for someone in the future that might need this, the main method to do it is using xml keyboards:只是对于将来可能需要这个的人,主要的方法是使用 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>

Then create every relevant keyboard under the folder "xml", with xml formatting:然后在“xml”文件夹下创建每个相关的键盘,格式为 xml:

在此处输入图像描述

Formatting within the pop-up keyboard:在弹出式键盘中进行格式化:

<?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>

There is an option as well to add pop-up characters, but I'm not sure if that support entering full strings, which you might want to if needing to input ".com", ".net", &c.还有一个选项可以添加弹出字符,但我不确定它是否支持输入完整的字符串,如果需要输入“.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