In this tutorial we will learn to implement marathi/hindi font in an android application which consists an text view, to display the text.
- To implement marathi/hindi font in android application follow the steps given below :
- First of all open up Android eclipse :
- Go to File->New->Android Application Project
- You will get a dialog box where you have to provide the details for your applicaiton :
- After filling the details you will have the following view of your Dialog box :
- Now click on Next button, you will get another dialog box where you just have to uncheck the first icon :
- After this click on the Next button, it will ask to select a Activity. So, select Blank Activity and click on Next button :
- Your Blank Activity will get created, so now click on the Finish button :
- Your project will be created as shown below :
- Now download the font which ever you like for example marathi font “mangla” and paste it in the assets folder as shown in the image below :
- Now let’s design our layout. So, go to activity_main.xml file and drag and drop the TextView as shown in the image :
- Now save your work by pressing Ctrl + S .
- Now go to MainActivity.java file and write the following code in it :
- Now go to Your activity_main.xml file and insert your Marathi / Hindi text in the text property of the TextView as shown in the image.
- Now select your project and run it as shown :
- Thus you will have following Output on your emulator…
- For inserting the image you can copy and paste the image in res->drawable folder
import android.app.Activity; import android.graphics.Typeface; import android.os.Bundle; import android.widget.TextView; public class Acts7 extends Activity{ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.acts7); TextView text_view = (TextView)findViewById(R.id.textView1); Typeface font = Typeface.createFromAsset(getAssets(), "mangal.ttf"); text_view.setTypeface(font); } public void onStop() { super.onStop(); } }
Thus, we have successfully learnt how to implement hindi font in android application.