Custom popup for key of keyboard

橙三吉。 提交于 2019-12-01 17:37:04

问题


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

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

CapDroid


回答1:


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="¹½⅓¼⅛"/>



回答2:


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



来源:https://stackoverflow.com/questions/5988699/custom-popup-for-key-of-keyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!