Emoticons are a great way to express emotions and convey thoughts between us, that people of different languages can understand, even children.
This article guides you how to easily integrate emojis into the application, with many customizations using the SuperNova-Emoji library .
1. Simple integration
Here is the integrated syntax for Emojis Keyboard. EmojiIconActions ‘ constructor passes four parameters: Context, RootView, EmojiconEditText and ImageView.
Usually, passing the RootView original layout is the best option to display the Emojis Keyboard in all views.
EmojiconEditText a EditText with custom properties to allow the display more emoticons. And the last parameter ImageView will be used to switch between the regular keyboard and the emoji keyboard.
To display emojis in TextView , we will use EmojiconTextView . This is also a TextView with more customizable properties to enable emoji display
1 2 3 4 5 6 7 8 9 10 | EmojIconActions emojIcon= new EmojIconActions(this, rootView, emojiconEditText, emojiImageView); emojIcon.ShowEmojIcon(); |
If you want to use in layout xml, use normal EditText EmojiconEditText instead.
1 2 3 4 5 6 | <hani.momanii.supernova_emoji_library.Helper.EmojiconEditText android:id="@+id/emojicon_edit_text" android:layout_width="match_parent" android:layout_height="wrap_content" emojicon:emojiconSize="28sp" /> |
And use EmojiconTextView instead of TextView :
1 2 3 4 5 6 7 8 | <hani.momanii.supernova_emoji_library.Helper.EmojiconTextView android:id="@+id/emojicon_text_view" android:layout_width="wrap_content" android:layout_height="wrap_content" emojicon:emojiconSize="28sp"/> |
2. Change the default conversion icon
To switch between regular keyboard and emoji keyboard, you can call setIconsIds () method with two parameters: keyboard Icon ID and smiley Icon ID.
1 2 | emojIcon.setIconsIds(R.drawable.ic_action_keyboard,R.drawable.smiley); |
3.Use the device’s default Emoji
SuperNove-Emoji allows you to use emojis on your device in a simple way. You need to set the boolean value of the setUseSystemEmoji () and setUseSystemDefault ( ) methods to TRUE in every EmojiconTextView and EmojiconEditText that you use to display emojis.
1 2 3 4 5 6 7 | emojIcon.setUseSystemEmoji(true); textView.setUseSystemDefault(true); emojiconEditText.setUseSystemDefault(true); |