我知道豪设置自定义字体编程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