Surendra
Surendra

Reputation: 124

Unable to include custom font in android

I want to use "HelveticaNeue LT Std 45 Light" as font-family for textview in android. Can you plz give me suggestions......

i tried with

    <TextView
    android:id="@+id/myTitle"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:layout_toLeftOf="@+id/signout"
    android:fontFamily="Helvetica Neue Std Lt"
    android:gravity="center"
    android:text="Bookings"
    android:paddingRight="45dp"
    android:singleLine="true"
    android:textSize="20sp" />

but Booking appears as bold instead of light.

Upvotes: 0

Views: 343

Answers (1)

Zax
Zax

Reputation: 3010

First you need to add your custom font *.ttf file in the assets folder in your project directory. Now in your program you can add your custom font using the below code:

Typeface font=Typeface.createFromAsset(getAssets(), "monocorsiva.ttf");
TextView tv=(TextView) findViewById(R.id.appName);
tv.setTypeface(font);

Hope this might have helped you.

Upvotes: 3

Related Questions