Open top menu


In this blog we will add external Stylish Text  Fonts in android.

1.First you have to download text fonts.
2.Create fonts inside assets foder.
3.you can past the text font (.ttf extension) file.






MainActivity.java
...................................................................................................................................................................

package com.androidbeginner.testcode;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;

@SuppressLint("ResourceAsColor")
public class MainActivity extends Activity {

@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setTitle("HINDI FONT");
setContentView(R.layout.activity_main);

TextView textstyle1 = (TextView) findViewById(R.id.textView);
TextView textstyle2 = (TextView) findViewById(R.id.textView1);
TextView textstyle3 = (TextView) findViewById(R.id.textView2);
Typeface fonttextstyle1 = Typeface.createFromAsset(getAssets(),"fonts/Face Your Fears.ttf");
Typeface fonttextstyle2 = Typeface.createFromAsset(getAssets(),"fonts/DS-DIGIT.TTF");
Typeface fonttextstyle3 = Typeface.createFromAsset(getAssets(),"fonts/CircleD_Font_by_CrazyForMusic.ttf");
textstyle1.setTypeface(fonttextstyle1);
textstyle2.setTypeface(fonttextstyle2);
textstyle3.setTypeface(fonttextstyle3);


}


}
................................................................................................................................................................

activity_main.xml.
...................................................................................................................................................................

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/fragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/logoweb" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="androidbeginnerpoint"
        android:textColor="#ecaa00"
        android:layout_margin="5dp"
        android:textSize="30dp" />
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="androidbeginnerpoint"
        android:textColor="#ecaa00"
        android:layout_margin="5dp"
        android:textSize="30dp" />
    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="androidbeginnerpoint"
        android:textColor="#ecaa00"
        android:layout_margin="5dp"
        android:textSize="30dp" />

</LinearLayout>
...................................................................................................................................................................


try this code....

0 comments