Niranj Patel
Niranj Patel

Reputation: 33248

Custom popup for key of keyboard

I am making custom keyboard.. Now my question is that I want custom popup for key pressed. So, can I change it. popup of key like as this image

enter image description here

If any one know about this then please help me...

CapDroid

Upvotes: 5

Views: 5084

Answers (2)

Nathan Schwermann
Nathan Schwermann

Reputation: 31493

Yup, its not too hard at all. Just check out the time in the AOSP here. It's all done in the resource files, here is a short snippet. From the symbols.xml file of my keyboard project.

<Key android:codes="49" android:keyLabel="1" android:keyEdgeFlags="left"
     android:popupKeyboard="@xml/kbd_popup_template"
     android:popupCharacters="¹½⅓¼⅛"/>

Upvotes: 4

Barry Fruitman
Barry Fruitman

Reputation: 12656

It's easy. Just set the android:iconPreview attribute for the key, where my_icon_preview is the drawable for the preview popup.

In XML:

<Key android:codes="116"
     android:keyLabel="t"
     android:iconPreview="@drawable/my_icon_preview" />

In Java:

tKey.iconPreview = getResources().getDrawable(R.drawable.my_icon_preview);

Where tKey has the type Keyboard.Key (of course).

Upvotes: 1

Related Questions