我知道豪設置自定義字體編程Android應用程序內。 有沒有什麼方法來加載自定義字體(資產)的字體和Android框架將使用基於大膽,斜體等適當的文件?的Android設置的Roboto字體,加粗,斜體,普通,...(有點像自定義字體家族)
比如現在我想的Roboto字體設置爲某個TextView
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/Roboto/Roboto-Regular.ttf");
textView.setTypeface(typeface);
它工作正常。但因爲我設置TextView
中的XML佈局大膽,文本不加粗
<TextView
android:id="@+id/my_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="50dp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/my_text"
android:textColor="@color/my_foreground"
android:textSize="24dp" />
如何從資產加載字體正確,這將工作?
textView.setTypeface(typeface, Typeface.BOLD);
在我的資產目錄中只有一個「字體系列」
Roboto-Black.ttf
Roboto-BlackItalic.ttf
Roboto-Bold.ttf
Roboto-BoldCondensed.ttf
Roboto-BoldCondensedItalic.ttf
Roboto-BoldItalic.ttf
Roboto-Condensed.ttf
Roboto-CondensedItalic.ttf
Roboto-Italic.ttf
Roboto-Light.ttf
Roboto-LightItalic.ttf
Roboto-Medium.ttf
Roboto-MediumItalic.ttf
Roboto-Regular.ttf
Roboto-Thin.ttf
Roboto-ThinItalic.ttf
如何加載所有排字體/家庭裏面的字體?
看起來不錯,但格式被打破。爲什麼不在這裏粘貼相同的課程? – mente 2013-09-04 13:34:19
鏈接已損壞 – 2017-04-04 13:56:41