我有一個字體文件love.ttf(5mb)。我已將它放入資產文件夾。 這是我的代碼設置字體文本視圖android(來自字體文件)
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv=(TextView)findViewById(R.id.textView1);
Typeface tf=Typeface.createFromAsset(getAssets(),"love.ttf");;
tv.setTypeface(tf,Typeface.NORMAL);
tv.setTextSize(20);
}
的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:background="#4B67A1"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="おはようございます。" />
</LinearLayout>
當我運行它,我無法看到的文本! 如何加載大字體? 請幫幫我! 謝謝
看來這個問題應該是ttf文件。 – Jitendra
你解決了這個問題嗎?我遇到了這個問題,這實際上適用於Android 2.3+,但不是<2.2。 –