Text Style



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" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="100dp"
        android:text="@string/name"
        android:textColor="#0FF"
        android:textSize="30dp" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="20dp"
        android:text="@string/name"
        android:textColor="#f79900"
        android:textSize="30dp" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="20dp"
        android:text="@string/name"
        android:textColor="#FFF"
        android:textSize="30dp" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="20dp"
        android:text="@string/name"
        android:textColor="#0FF"
        android:textSize="30dp" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="20dp"
        android:text="@string/tamil"
        android:textColor="#0FF"
        android:textSize="45dp" />

</LinearLayout>

TextfontActivity.java


package moor.android.fontstyle;

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

public class TextfontActivity extends Activity {
    TextView tv,tv1,tv2,tv3,tv4;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        tv = (TextView) findViewById(R.id.textView1);
        tv1 = (TextView) findViewById(R.id.textView2);
        tv2 = (TextView) findViewById(R.id.textView3);
        tv3 = (TextView) findViewById(R.id.textView4);
        tv4 = (TextView) findViewById(R.id.textView5);
        Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/chalkdust.ttf");
        Typeface tf1 = Typeface.createFromAsset(getAssets(),"fonts/lcchalk_.ttf");
        Typeface tf2 = Typeface.createFromAsset(getAssets(),"fonts/patrick_hand.otf");
        Typeface tf3 = Typeface.createFromAsset(getAssets(),"fonts/PPETRIAL.otf");
        Typeface tf4 = Typeface.createFromAsset(getAssets(),"fonts/Amudham.ttf");
         tv.setTypeface(tf);
         tv1.setTypeface(tf1);
         tv2.setTypeface(tf2);
         tv3.setTypeface(tf3);
         tv4.setTypeface(tf4);
    }
}

Screen shot :




Download source...

3 comments: