Update
Since you want to use via XML
Your layout.xml should be like
<?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"
>
<com.nannu.NanTV
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/book"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
</LinearLayout>
and string.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="book"><![CDATA[jpujI swihb\<> siq nwmu krqw purKu inrBau inrvYruAkwl mUriq AjUnI sYBM gur pRswid ]] jpu ]Awid scu jugwid scu ]hY BI scu nwnk hosI BI scu ]1]socY soic n hoveI jy socI lK vwr ]cupY cup n hoveI jy lwie rhw ilv qwr ]BuiKAw BuK n auqrI jy bMnw purIAw Bwr ]shs isAwxpw lK hoih q iek n clY nwil ]ikv sicAwrw hoeIAY ikv kUVY qutY pwil ]hukim rjweI clxw nwnk iliKAw nwil ]1]hukmI hovin Awkwr hukmu n kihAw jweI ]hukmI hovin]]></string>
</resources>
Hello Extend your textview
package com.nannu;
import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;
public class NanTV extends TextView{
private Context c;
public NanTV(Context c) {
super(c);
this.c = c;
Typeface tfs = Typeface.createFromAsset(c.getAssets(),
"font/bulara_5.ttf");
setTypeface(tfs);
}
public NanTV(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.c = context;
Typeface tfs = Typeface.createFromAsset(c.getAssets(),
"font/bulara_5.ttf");
setTypeface(tfs);
// TODO Auto-generated constructor stub
}
public NanTV(Context context, AttributeSet attrs) {
super(context, attrs);
this.c = context;
Typeface tfs = Typeface.createFromAsset(c.getAssets(),
"font/bulara_5.ttf");
setTypeface(tfs);
}
}
Now Your layout.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"
>
<com.nannu.NanTV
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
</LinearLayout>
Activity
package com.nannu;
import android.app.Activity;
import android.os.Bundle;
public class NanDempoActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
NanTV nan = (NanTV)findViewById(R.id.textView1);
nan.setText("jpujI swihb<> siq nwmu krqw purKu inrBau inrvYruAkwl mUriq AjUnI sYBM gur pRswid ]] jpu ]Awid scu jugwid scu ]hY BI scu nwnk hosI BI scu ]1]socY soic n hoveI jy socI lK vwr ]cupY cup n hoveI jy lwie rhw ilv qwr ]BuiKAw BuK n auqrI jy bMnw purIAw Bwr ]shs isAwxpw lK hoih q iek n clY nwil ]ikv sicAwrw hoeIAY ikv kUVY qutY pwil ]hukim rjweI clxw nwnk iliKAw nwil ]1]hukmI hovin Awkwr hukmu n kihAw jweI ]hukmI hovin");
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…