更新
XML経由で使用したいので、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="@string/book"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
</LinearLayout>
および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>
こんにちは、テキストビューを拡張します
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);
}
}
今あなたの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>
アクティビティ
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");
}
}