I am developing a custom keyboard for android. I am trying to create a button when pressed smiley faces should popup. It has come to my understanding that android:popupCharacters is responsible for displaying a popup on the keyboard as well as android:popupKeyboard. My problem is that for example if i put android:popupCharacters=":) :(" i get a popup with each character on a button by itself. How is it done?
Thanks in advance
Read the doc carefully: http://developer.android.com/reference/android/inputmethodservice/Keyboard.Key.html#attr_android:popupCharacters
android:popupCharacters
The characters to display in the popup keyboard.
[...]
android:popupKeyboard
The XML keyboard layout of any popup keyboard.
So popupcharacters means a simpler way to create popupkeyboard. But Unicode comes and saves you from creating XML and using images: http://unicodeemoticons.com/ Try them! (Once I tried a long time ago, well displayed on 2.2 emulator, ZTE Blade and T-Mobile Pulse / Huwaei U8220).
If you don't want this workaround, the other soulution is if you go into the android SDK source, and try to reimplement the whole popup keyboard (or over-implement, if you can) to make it available for you. But anyway, if I was the user, I would be more happy for the unicode or the images, but this is only my opinion.
Create a separate xml layout for popups in xml directory as the following
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="15%p"
android:horizontalGap="0px"
android:verticalGap="0px"
android:keyHeight="@dimen/key_height"
>
<Row android:rowEdgeFlags="top">
<Key android:keyLabel=":-)" android:keyOutputText=":-) "
<Key android:keyLabel=":-)" android:keyOutputText=":-( "
</Row>
</Keyboard>
Add as many row and/or key attributes as you like for additional smileys then use this in your keyboard xml
<Key android:keyOutputText=":-)" android:keylabel=":-)" android:popupKeyboard="@xml/popup"/>
This will create a key ":-)" which will output the character :-) if you press it once, and use the popup xml layout when you long press it.
If you are making your own keyboard then check this following source code available which will help you a lot.
Scandinavian-keyboard
Hackers Keyboard
Android Emoji Keyboard
Also you want to change theme of your keyboard then check following link.It will give you clear idea of how to make preview layout and all. And specially if you want to check about smiley then Android Emoji Keyboard will be very useful. It uses smiley symbols in keyboard and also in preview too.
Hope this will help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With