Creating a SoftKeyboard with Multiple/Alternate characters per key
Implementing alternate key popup:
For each key you wish to have a popup keyboard you should define popupCharacters and popupKeyboard:
/res/xml/[Keyboard].xml
<Key android:keyLabel="("
android:popupKeyboard="@xml/keyboard_popup_template"
android:popupCharacters="[{<" />
The popupKeyboard
is an XML representation of the keyboard used in the popup containing the alternate keys:
/res/xml/keyboard_popup_template.xml
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="10%p"
android:horizontalGap="0px"
android:verticalGap="0px"
android:keyHeight="56dp">
</Keyboard>
Styling the alternate key popup:
If you want to change the layout/style of the popup (which defaults to @android:layout/ keyboard_popup_keyboard.xml) you can specify a android:popupLayout
attribute which points to a layout file:
<android.inputmethodservice.KeyboardView
android:id="@+id/keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#FF272727"
android:popupLayout="@layout/keyboard_popup_keyboard" />
Implementing Key Preview Overlay:
The only solution I've been able to knock together to show key previews (Without entirely rewriting the KeyboardView source code) is below:
Wrapping the <KeyboardView>
tag with a <FrameLayout>
with a height specified by multiplying the keyHeight by the amount of rows. Inside this tag I've simply created a LinearLayout to hold rows, then a LinearLayout for each row containing a TextView with a weight equal to the %p value specified for each <Key>
:
<TextView android:text="!" style="@style/Custom.Widget.KeyboardKeyOverlay" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="10"/>
And styled:
<style name="CustomTheme.Widget.KeyboardKeyOverlay">
<item name="android:background">@android:color/transparent</item>
<item name="android:textColor">#FFAAAAAA</item>
<item name="android:paddingRight">6dp</item>
<item name="android:paddingTop">4dp</item>
<item name="android:textSize">10sp</item>
<item name="android:gravity">right</item>
<item name="android:textStyle">bold</item>
</style>
Which produces this:
I won't be happy until I've managed to implement this in the same way as the System Keyboard does!
display multiline/multiple characters as key label on soft keyboard keys
Hi I have done it with by taking reference of Customize the appearance of a <Key>
By playing with given code after three days i have got my solution.
Related Topics
How to Add a Fast-Scroller to the Recyclerview
How Is Staticlayout Used in Android
Android Speech Recognition Continuous Service
Pathpattern to Match File Extension Does Not Work If a Period Exists Elsewhere in the File Name
Android:Get View Reference to a Menu Item
Actionbaractivity Cannot Resolve a Symbol
Design Layout for Multiple Screens
Bluetooth and Wifi Printing for Android
How to Show an Empty View with a Recyclerview
Adb Install Fails with Install_Failed_Test_Only
Error: Resource Android:Attr/Fontvariationsettings Not Found
Why Do I Get Com.Google.Android.Gms.Common.Api.Apiexception: 10:
Apache Commons Codec with Android: Could Not Find Method
How to Perform Collection Group Query Using Document Id in Cloud Firestore