简体   繁体   English

Roboto字体是否适用于Android 4+?

[英]Roboto font for Android 4+?

Do I need to use Roboto font and put it to asset folder if my app will support only Android 4+ devices? 如果我的应用程序仅支持Android 4+设备,是否需要使用Roboto字体并将其放入资产文件夹?

I would greatly appreciate for your help. 我非常感谢你的帮助。 Alex. 亚历克斯。 PS Sorry for my English:) PS抱歉我的英文:)

You can use Roboto natively from Android 4.1+ like this: 您可以使用Android 4.1+本机的Roboto,如下所示:

android:fontFamily="sans-serif"           // roboto regular
android:fontFamily="sans-serif-light"     // roboto light
android:fontFamily="sans-serif-condensed" // roboto condensed

For any version below that, you have to load the font yourself. 对于以下任何版本,您必须自己加载字体。 Look at this answer I gave a while back for more information. 看看这个答案,我暂时回过头来了解更多信息。

Answer 回答

Ok. 好。 I think, I got it. 我想,我明白了。

Samsung phones are by far the most popular Android phones. 三星手机是迄今为止最受欢迎的Android手机。 Whilst it's true that all Samsung phones from 4.1 and up have Roboto, they also have something called Samsung Sans, and if your user has set it as their default font then the android:font-family (as @Ahmad says) requests all return Samsung Sans, not Roboto. 虽然所有来自4.1及以上的三星手机都拥有Roboto,但他们也有一款名为Samsung Sans的东西,如果你的用户将其设置为默认字体,那么android:font-family(如@Ahmad所说)请求全部返回三星Sans,而不是Roboto。 If you have fixed tight layouts with no wriggle-room that can't stretch, Samsung Sans will break them. 如果你有固定的紧凑布局,没有无法伸展的蠕动空间,三星Sans将打破它们。 There's no easy way round this. 围绕这个没有简单的方法。 If you absolutely have to have Roboto, you must package it as an asset and set it as the typeface explicitly. 如果您必须拥有Roboto,则必须将其打包为资产并将其明确设置为字体。

Thx to @Ahmad as well as @Kenton Price's comment here: https://stackoverflow.com/a/14633032/2553905 感谢@Ahmad以及@Kenton Price的评论: https ://stackoverflow.com/a/14633032/2553905

To add to Ahmad's excellent answer, you can swap out 'light' or 'condensed' to whichever style it is you want from the list in the Material Design guidelines here: 要添加Ahmad的优秀答案,您可以从“材料设计指南”中的列表中将“浅色”或“浓缩”换成您想要的任何样式:

http://www.google.com/design/spec/style/typography.html#typography-roboto-noto http://www.google.com/design/spec/style/typography.html#typography-roboto-noto

For example: 例如:

android:fontFamily="sans-serif-medium"     // roboto medium

And so on. 等等。 This comment adds no more than Ahmad's, but just clears up that you are not limited to the 3 examples he gave, you can use any. 这个评论只增加了艾哈迈德,但只是清楚你不仅限于他给出的3个例子,你可以使用任何。

From documentation: 来自文档:

Ice Cream Sandwich introduced a new type family named Roboto, created specifically for the requirements of UI and high-resolution screens. Ice Cream Sandwich推出了一个名为Roboto的新型系列,专为UI和高分辨率屏幕的要求而设计。

Read more about Typography . 阅读更多关于排版的信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM