How to Set Emoji by Unicode in a Textview

How to set emoji by unicode in a textview?

Found a solution:

In my unicode I replaced 'U+' by '0x'

Example: replace 'U+1F60A' by '0x1F60A'

This way I got an 'int' like

int unicode = 0x1F60A;

Which can be used with

public String getEmojiByUnicode(int unicode){
return new String(Character.toChars(unicode));
}

So Textview displays without Drawable

Try it with http://apps.timwhitlock.info/emoji/tables/unicode

Display \u00F0\u009F\u0098\u0098 string to emoji in android textview?

String title = new String(c.getString("title").getBytes("ISO-8859-1"), "UTF-8");

While Parsing the response I used this now instead of:

String title = String(c.getString("title");

This solved my emoji issue.

How to set unicode in textview to show emoji in android?

This sounds like you want to unescape your string that you've got from JSON. If you don't mind adding a library, Apache Commons has a String.unescapeJava function which does what you need. If you don't want to add that library, see this answer.

How to can i add emoji in text using 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);

Display emoji/emotion icon in Android TextView

You could also try to find the emoji using a regular expression: "[\ue415\ue056\ue057]", instead of comparing the bytes. /p>

Cannot display a Unicode character (Emoji) in an Android TextView with large text: Font size too large to fit in cache

It's an android issue Issue with emoji with 200sp size
No way to fix it at the moment, just don't set size more than 199 if you have emoji in TextView

How to change color of unicode character in TextView?

To make it RED you have to set it's textColor RED. Like this way ->

TextView tv=(TextView)findViewById(R.id.testText);
tv.setText(Html.fromHtml("\u2665"));
tv.setTextColor(Color.RED); // Set color here


Related Topics



Leave a reply



Submit