Jannatul Ferdaus Jannatul Ferdaus - 6 months ago 19
Java Question

How to set Bangla font to a TextView in Android

Hi i am a Bangladeshi.

I am new in Android programming.

I have a EditText. I need to set Bangla on it.

what can i do.

<EditText android:id="@id+/title"
android:width="fill_parent"
android:height="200dp"
android:text="ঘূর্ণিঝড় রোয়ানুর কারণে"
/>

Answer

Download your font and keep it in assets folder. Write your text that you set to TextView in strings.xml in values folder

<string name="text_of_title">ঘূর্ণিঝড় রোয়ানুর কারণে</string>

Now add it to TextView like this

<EditText android:id="@id+/title"
      android:width="fill_parent"
      android:height="200dp"
      android:text="@strings/text_of_title"/>

Now write java code to add the font to the TextView

TextView title = (TextView) findViewById(R.id.title);
String BANGLA_FONT_SOLEMAN_LIPI = "/SOLAIMANLIPI_22-02-2012.TTF";
Typeface tf = Typeface.createFromAsset(con.getAssets(),
 BANGLA_FONT_SOLEMAN_LIPI);
title.setTypeface(tf);

Thats all. I hope you will enjoy it.

Comments