We all have used emojis extensively, want to show you are laughing you send an emoji, want to send a kiss, you send an emoji. Emojis constitute a language understood by one and all irrespective of age, sex, race, religion or origin. Most of the social platforms offer different sets of emojis. Why not integrate them with your own custom application.
The following article explains how this integration can be done with various customization options available using SuperNova-Emoji library.
1. Simple Integration
Below is the syntax of a simple integration for Emojis Keyboard. The EmojiIconActions constructer accept four parameters, Context, RootView, EmojiconEditText, and ImageView. Usually passing the parent layout as RootView is the best option to show the Emojis Keyboard above all views. The EmojiconEditText is a EditText with more custom attributes to enable emojis rendering. And the last parameter the ImageView will used to switch between the normal keyboard and the emojis keyboard.
To display emojis in TextView we will use EmojiconTextView which is also a TextView with more custom attributes to enable emojis rendering
If you want to use it in xml layout, we will use EmojiconEditText instead of the normal EditText.
And EmojiconTextView instead of TextView
2. Change the default Toggle Icon
For switching between normal keyboard and emojis keyboard, you can call setIconsIds() method which takes two parameters, keyboard Icon ID and smiley Icon ID.
3. Using device default Emojis
SuperNove-Emoji allow you to use device emojis ins simple way, you need to set the boolean value of setUseSystemEmoji() and setUseSystemDefault() methods to TRUE in every EmojiconTextView and EmojiconEditText you use to display the emojis.
4. Changing Emojis Size
In order to change Emojis size, you have to change the text size by setting the value of setEmojiconSize() method.
5. Detect When the Keyboard Opened or closed
SuperNova-Emoji let you detect when the user open the keyboard or close it to take some actions if needed like show some views when the keyboard open and hide it when the keyboard closed. Use the below code block to achieve this.
6. Changing the Emoji Keyboard colors to match your app theme
You can set three colors to the emojis keyboard by adding three parameters to the constructer which they are pressed tabs icons color, tabs color, and background color. We will use the same above constructer with the colors value.
7. Creating Sample App
Now we’ll create a simple app integrating the emojis to get a good understanding of it in a real app.
1. In Android Studio, go to File ⇒ New Project and fill all the details required to create a new project.
2. Open build.gradle and add supernova emoji library. You need to add its maven repository too.
3. Open the layout file your main activity activity_main.xml and add below code. Here you can see that I have added the emojiconEditText, emojiconTextView and the ImageView.
4. Now open MainActivity.java and make the changes as mentioned below. This activity show the different scenarios of implementing the SuperNova-Emoji as explained above.
Run And test the app.
Download a source code from here