Home > Enterprise >  Add a submenu in an Android Keyboard?
Add a submenu in an Android Keyboard?

Time:12-15

I'm trying to create a custom Android Keyboard, just trying to learn the process. enter image description here

I've been relatively successful, as I'm just learning the basics for now:

enter image description here

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?

enter image description here

Any help is appreciated.

CodePudding user response:

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:

enter image description here

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>
  • Related