so typeface has 4 or 5 font styles, what if we need some other. I found textappearance can do that but how?
Asked
Active
Viewed 1,288 times
0
-
Bro first do Google..!!! – Nils Mar 01 '16 at 13:04
-
2what you exactly want?? – Nils Mar 01 '16 at 13:06
-
Please try to search before posting. http://stackoverflow.com/questions/5634245/how-to-add-external-fonts-to-android-application – Rohit5k2 Mar 01 '16 at 13:07
2 Answers
1
Create a folder called fonts under assets folder and place all your fonts in it. (Folder name can be anything)
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#222222" >
<TextView
android:id="@+id/ghost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="70dip"
android:gravity="center"
android:textColor="#ef0000"
android:layout_marginTop="50dip"
android:text="ghost" />
</LinearLayout>
SampleActivity.java
package com.example;
import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;
public class AndroidExternalFontsActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Font path
String fontPath = "fonts/Face Your Fears.ttf";
// text view label
TextView txtGhost = (TextView) findViewById(R.id.ghost);
// Loading Font Face
Typeface tf = Typeface.createFromAsset(getAssets(), fontPath);
// Applying font
txtGhost.setTypeface(tf);
}
}

Sabyasachi
- 3,499
- 2
- 14
- 21
0
First create assets folder and then create fonts folder in assets folder.
TypeFace customTypeFace=Typeface.createFromAsset(getAssets(),"fonts/mytruetypefont.ttf");
Textview.setTypeface(typeFace);

Emre Tekin
- 462
- 7
- 18