Custom popup for key of keyboard

妖精的绣舞 提交于 2019-12-01 18:15:46

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

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

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