简体   繁体   中英

Add a submenu in an Android Keyboard?

I'm trying to create a custom Android Keyboard, just trying to learn the process. 在此处输入图像描述

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

在此处输入图像描述

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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