Display All Unicode Chars in Textview

Display all Unicode chars in TextView

tv=(TextView)findViewById(R.id.textView1);
Typeface font= Typeface.createFromAsset(getAssets(), "TAU_BHON.TTF");
tv.setTypeface(font);

Place the font that will support your language in the assets folder.In this case i have used TAU_BHON.TTF

Unicode characters not displayed in TextView.setText

Unfortunately, you just can't do it that way from strings.xml AFAIK.

You're left doing one of two things.

  • Adding the Unicode character within java to the String in the XML file:

    String str = "\u00A9" + getContext().getString(R.string.your_string);
  • Entering the text as HTML in java:

    yourTextView.setText(Html.fromHtml("your chars"));

Hope this is useful.

How to show Unicode character in a TextView in Android?

You can parse unicode from html to string by using HTML library like

val bullet = "•"
print("this is bullet a ${Html.fromHtml(bullet)}")

How can I display special characters (like –) in the TextView?

You can use the Html.fromHtml() to handle HTML formatted text into a Spannable that TextView can display.

Android: TextView, unicode character not shown properly

Some fonts don't support some characters. Check your message is shown with other font; include the ttf file on your assets folder, and set the content of the TextView with that font with something like:

yourTextView=(TextView)findViewById(R.id.idOfYourTextView);
Typeface font= Typeface.createFromAsset(getAssets(), "The_Font.TTF");
yourTextView.setTypeface(font);

Hope it helps.



Related Topics



Leave a reply



Submit