Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Special characters in a TextView

I want to show the "♫" character in an Android TextView, but it shows [] instead.

This is my code:

txtCatname.setText("♫");

How can I display this symbol correctly?

like image 904
Alireza Avatar asked May 12 '14 12:05

Alireza


People also ask

How do I add special characters to my Android?

Sometimes you need to add special character as Text in your android app. They are called as Unicode Character. For Android, we have to mention their Unicode number as String and set to textview like Rupee Symbol(₹), bullet, tick mark, star, etc.. Now add textview in your activity_main.

Which is a attribute of TextView?

The attribute which is used to change the size of the Text View in android is “textSize”.


1 Answers

You can use an Unicode code: http://unicode-table.com/en/.

Such as:

txtCatname.setText("\u266b");

or alternatively use an iconic font, such as font awesome:
http://fortawesome.github.io/Font-Awesome/

Use this alternative (or any other iconic font you like), in case this character isn't supported (not all Unicode characters are supported).

like image 99
Phantômaxx Avatar answered Sep 23 '22 16:09

Phantômaxx