Android 版 Google Fonts 使用入门
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android O 和 AndroidX 库增加了对
可下载字体。
Google Fonts 是 Google Play 服务中的一个字体提供程序。这意味着
Google Fonts 可用于 Android 设备上的原生应用!
我可以使用哪些字体?
整个 Google Fonts 开源集合!请访问
前往 https://fonts.google.com 进行浏览。
支持哪些 Android 版本?
我们的提供商支持 Jelly Bean(API 级别 16)及更高版本。这代表了 95%以上的
的野外 Android 设备
(平台信息中心)。
可使用 AndroidX 库中的 API 进行访问
(androidx.core)
或 Android O(API 级别 26)。
该从何处入手!
如需向 Google Fonts 提供程序请求字体,请使用以下查询格式:
参数 |
是否必需? |
Range |
数据类型 |
默认值 |
name |
是 |
来自 Fonts.google.com 的任何系列 |
字符串 |
|
width |
否 |
> 0 |
float |
100 |
重量 |
否 |
(0, 1000) 不包括 |
int |
400 |
斜体 |
否 |
[0, 1](含) |
float |
0 |
尽力而为 |
否 |
true/false |
布尔值 |
true |
如果 besteffort 为 true,并且您的查询指定了一个有效的系列名称,但
不支持所请求的宽度/重量/斜体值,我们将返回最佳尺寸
匹配。例如,
权重为 900 的 Oswald 会返回
奥斯瓦尔德的体重为 700 分。
示例查询:
name=Lobster # Lobster, 400 weight
name=Lato&weight=100 # Lato, 100 weight
name=Open Sans&weight=800&italic=1 # Open Sans, 800 weight, italic
安全
出于安全考虑,您必须指定公开
请求字体的提供程序Android Studio 会将
正确签名。请参阅
添加证书。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-08-22。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2024-08-22。"],[[["Android now supports downloadable fonts, including the entire Google Fonts collection, via Android O and AndroidX Library."],["Google Fonts are readily available for native Android apps through a Font Provider in Google Play Services, supporting Android Jelly Bean (API level 16) and above."],["Developers can access Google Fonts declaratively or programmatically and easily customize font attributes like width, weight, and italic style."],["A built-in \"best effort\" feature ensures the closest font match if the specific requested style is unavailable within the chosen font family."],["For security, applications utilizing the Google Fonts provider must specify the provider's signature, a process simplified within Android Studio."]]],[]]