Pop-up layout in soft keyboard for Android?

I am currently studying soft keyboard implementation in android. One thing I'm confused with is where to implement the small square of the popup when you press any key (I am attaching two examples below).

I read the example of the Soft Keyboard application presented in the SDK, it has this function, but I can’t find which code code implements it.

Any ideas on how I could implement / modify it?

Soft Keyboard Application Example

sample keyboard

Default android keyboard

android default keyboard

+4
source share
2 answers

This is your preview layout.

Sample code for preview.xml file

<?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#ffffff" android:gravity="center" android:textColor="@color/black" android:textSize="30sp" android:textStyle="bold" > </TextView> 

Call up your preview on the keyboard. xml:

 android:keyPreviewLayout="@layout/preview" 

Or you can create a class that extends KeyboardView and implements your own code for preview.

+1
source

The part that controls this is in the LatinKeyboardView class

 @Override protected boolean onLongPress(Key key) { if (key.codes[0] == Keyboard.KEYCODE_CANCEL) { getOnKeyboardActionListener().onKey(KEYCODE_OPTIONS, null); return true; } else { return super.onLongPress(key); } } 

Part of your look is in else .

Now this calls super.onLongPress(key) , which is in the KeyboardView .

To configure an override of else with the appropriate code.

Here you will find the link

0
source

All Articles