How to implement hindi font in android application

0
20545

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 :

  1. First of all open up Android eclipse :
  2. eclipse

  3. Go to File->New->Android Application Project
  4. Create new project

  5. You will get a dialog box where you have to provide the details for your applicaiton :
  6. application details

  7. After filling the details you will have the following view of your Dialog box :
  8. details

  9. Now click on Next button, you will get another dialog box where you just have to uncheck the first icon :
  10. configuration file

  11. After this click on the Next button, it will ask to select a Activity. So, select Blank Activity and click on Next button :
  12. Activity Creation

  13. Your Blank Activity will get created, so now click on the Finish button :
  14. Activity Created

  15. Your project will be created as shown below :
  16. Marathi

  17. 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 :
  18. assets

  19. Now let’s design our layout. So, go to activity_main.xml file and drag and drop the TextView as shown in the image :
  20. drag

  21. Now save your work by pressing Ctrl + S .
  22. Now go to MainActivity.java file and write the following code in it :
  23. 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();
    	}
    
    }
    

  24. 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.
  25. Hindi Text

  26. Now select your project and run it as shown :
  27. Run

  28. Thus you will have following Output on your emulator…
  29. Cow

  30. For inserting the image you can copy and paste the image in res->drawable folder
  31. Inserting image

Thus, we have successfully learnt how to implement hindi font in android application.

LEAVE A REPLY

Please enter your comment!
Please enter your name here