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