결과화면

 

폰트 넣기

 

// FontDemo.java

 

 package com.example.hellow;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class FontDemo extends Activity{
 
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  // TODO Auto-generated method stub
  super.onCreate(savedInstanceState);
  setContentView(R.layout.font_demo);
  
  TextView text = (TextView)findViewById(R.id.myfont);
  Typeface face = Typeface.createFromAsset(getAssets(), "font/samplefont.ttf");
  text.setTypeface(face);
  
 }
 

}

 

 

//   font_demo.xml

 

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="sans"
        android:typeface="sans" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="serif"
        android:typeface="serif" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="monospace"
        android:typeface="monospace" />

    <TextView
        android:id="@+id/myfont"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="myfont"
        android:typeface="sans" />

</LinearLayout>

 

+ Recent posts