Monday 29 October 2012

How to use custom font and style android

How to use custom font and style android
  • How to set custom Font face in android.
  • How to change font of the TextView
  • Set Font run time in android.
  • How to change Font face run time in android.  
  • Setting Font face of TextView,EditText in android.
  • Download free android tutorial for how to set Font face.
  • Android setting font face run time example code.



           This is a simple tutorial for android beginner which will help you to understand how to use custom fonts in your android app.

Android allows user to set Fonts in easier way.

But there is one limitation that you can't set font face using xml, you must need to set font face using code(run time).

You can set Font face of TextView as well as EditText run time.

Steps to set custom fonts in android.
  • Create one TextView  using xml.
    <TextView
    android:id="@+id/tv_example"
    android:text="gtu mca"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >


  • Give reference in java code
     TextView tvExample = (TextVi1ew)findViewById(R.id.
    tv_example);
     
  •  Put Font face file in your assets folder
     
    find from below sample code Fiance.otf
     
  • Create and Initialize object of TypeFace from assets folder 
    Typeface font = Typeface.createFromAsset(getAssets(),Fiance.otf");
     
  • Set Font face to TextView
    tvExample
    .setTypeface(font);
     
  • Build and run your project.
     
  • Here you goes...
GTU MCA Custom Font Demo Download For Free - Free Android Tutorial
 

Related Links  
  1. Get number of lines lines of TextView in Android.
  2. How to create simple TextView in android.
  3. Latest IT news updates 

0 comments:

Post a Comment

Fill free to post your Queries and Suggesion...!

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Bluehost Review