1. Select the font you like and download the font file
Font reference: http://www.creativebloq.com/graphic-design-tips/best-free-fonts-for-designers-1233380
2. Create a new font folder in the project assets file and place your font file in the folder
3. Project Code
Layout code:
[HTML] View PlainCopy
- <? XML version= "1.0" encoding="Utf-8"?>
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <TextView
- android:id="@+id/defaultfonttext"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textsize="30sp"
- android:text="Here is some text." />
- <TextView
- android:id="@+id/customfonttext"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textsize="30sp"
- android:text="Here is some text." >
- </TextView>
- </linearlayout>
Activity code:
[Java] View PlainCopy
- Public class Main extends Activity {
- @Override
- public void OnCreate (Bundle savedinstancestate) {
- super.oncreate (savedinstancestate);
- Setcontentview (R.layout.main);
- Typeface tf = Typeface.createfromasset (Getassets (),
- "FONTS/BPREPLAY.OTF");
- TextView TV = (TextView) Findviewbyid (R.id.customfonttext);
- Tv.settypeface (TF);
- }
- }
4.
5. SOURCE Link
http://www.barebonescoder.com/2010/05/android-development-using-custom-fonts/
Android Custom Font Examples