在 Android 中使用自定义字体 [英] Using a custom typeface in Android

查看:42
本文介绍了在 Android 中使用自定义字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我正在创建的 Android 应用程序使用自定义字体.
我可以从 Code 中单独更改每个对象的字体,但我有数百个.

I want to use a custom font for my android application which I am creating.
I can individually change the typeface of each object from Code, but I have hundreds of them.

所以,

  • 有没有办法从 XML 中做到这一点?[设置自定义字体]
  • 有没有办法从一个地方的代码中做到这一点,也就是说整个应用程序和所有组件都应该使用自定义字体而不是默认字体?

推荐答案

有没有办法从XML?

Is there a way to do this from the XML?

不,抱歉.您只能通过 XML 指定内置字体.

有没有办法从代码中做到这一点一个地方,说整个应用程序和所有组件应该改用自定义字体默认的?

Is there a way to do it from code in one place, to say that the whole application and all the components should use the custom typeface instead of the default one?

我不知道.

现在有多种选择:

  • Android SDK 中的字体资源和向后移植,如果您使用的是 appcompat

第三方库,适用于那些不使用 appcompat,虽然不是所有的都支持在布局资源中定义字体

Third-party libraries for those not using appcompat, though not all will support defining the font in layout resources

这篇关于在 Android 中使用自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆