I want to add an emoji to a predefined text view. User no need to change that. How can i achieve this
"Hi there 😀!"
in TextView
in Android using emoji library ? Do i need to use emoji library ?
You don't need a library for this.
Method 1
Suppose you have a textview, then try this
textView.setText(new String(Character.toChars(0x1F60A)));
where 0x1F60A is the unicode for your smiley
Alternate Method
add this resource in strings.xml
<string name="smiley_text">😊</string>
then add it to textview like below
textview.setText(R.string.smiley_text);
Check this library https://github.com/vanniktech/Emoji
implementation 'com.vanniktech:emoji-ios:0.5.1'
Add this line to onCreate inside Application class.
EmojiManager.install(new IosEmojiProvider()); // This line needs to be executed before any usage of EmojiTextView, EmojiEditText or EmojiButton.
Then use EmojiEditText & EmojiTextView
<com.vanniktech.emoji.EmojiTextView
android:id="@+id/emojiTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Update
Use EmojiCompat
Add the support library to the dependencies section.
dependencies {
...
compile "com.android.support:support-emoji:27.1.1"
}
Use EmojiCompat widgets in layout XMLs. If you are using AppCompat, refer to the Using EmojiCompat widgets with AppCompat section.
<android.support.text.emoji.widget.EmojiTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Update 2
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