在 Android 中使用自定义字体

编程入门 行业动态 更新时间:2024-10-26 00:19:19
本文介绍了在 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 中使用自定义字体

本文发布于:2023-11-07 22:31:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1567615.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   字体   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!