views:

156

answers:

2

Hello.... i have already read some articles and searched on google.....but i am failed to do it.

My problem is regarding the font-face.

In android, there are only 4 attributes in "android:typeface"...which are Normal,Sans, Serif, Monospace...

so what i have to do to use "Verdana" in my application ? pls suggest me a correct way to use this font in my android application....

+1  A: 

This is a simple example... create a folder in the root of your project called assets/fonts/ then paste the TTF font file (in this case Verdana.ttf). Then, if you want to apply that font to, say a TextView, do the following:

public class FontSampler extends Activity {
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);

    TextView tv=(TextView)findViewById(R.id.custom);
    Typeface face=Typeface.createFromAsset(getAssets(),
                                          "fonts/Verdana.ttf");

    tv.setTypeface(face);
  }
}

This example was taken from the ComonsWare book (written by Mark Murphy). You can download the full example from GitHub.

Cristian