android 平方常规字体,android - Android将Roboto字体设置为粗体,斜体,常规,…(类似于自定义字体系列) - 堆栈内存溢出...

我知道如何在Android应用程序中以编程方式设置自定义字体。 有什么方法可以为自定义字体(资产)加载字体,Android框架将使用基于粗体,斜体等的正确文件吗?

例如现在我正在尝试将Roboto字体设置为某些TextView

Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/Roboto/Roboto-Regular.ttf");

textView.setTypeface(typeface);

可以。 但是由于我将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

如何在一个字体/家族中加载所有这些字体?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值