Special Character in Android

Droid By Me
1 min readJan 5, 2018

--

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..

We show you some of the Unicode character with their Unicode number. You have to define those Unicode numbers in strings.xml file and refer them to textview as below:

<string name=”Rs”>\u20B9</string>
<string name=”filled_bullet”>\u25CF</string>
<string name=”linear_bullet”>\u25CB</string>
<string name=”rect_bullet”>\u25A0</string>
<string name=”blank_rect”>\u25A1</string>
<string name=”true_tick”>\u2713</string>
<string name=”star”>\u2605</string>

Now add textview in your activity_main.xml for each value like this:

<?xml version=”1.0" encoding=”utf-8"?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android"
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:layout_gravity=”center”
android:layout_margin=”16dp”
android:gravity=”center”
android:orientation=”vertical”>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”@string/Rs”
android:textSize=”38sp” />
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”@string/filled_bullet”
android:textSize=”38sp” />
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”@string/linear_bullet”
android:textSize=”38sp” />
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”@string/rect_bullet”
android:textSize=”38sp” />
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”@string/blank_rect”
android:textSize=”38sp” />
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”@string/true_tick”
android:textSize=”38sp” />
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”@string/star”
android:textSize=”38sp” />
</LinearLayout>

Here’s output for above code snippet:

For more Unicode number for Unicode character, visit https://unicode-table.com/en/

--

--

Droid By Me
Droid By Me

Written by Droid By Me

By profession and passion : Android Developer

Responses (1)