Roboto font for Android 4+?
Asked Answered
S

4

20

Do I need to use Roboto font and put it to asset folder if my app will support only Android 4+ devices?

I would greatly appreciate for your help. Alex. P.S. Sorry for my English:)

Sherri answered 1/10, 2013 at 10:6 Comment(3)
Do you want to know how to it or what do you mean exactly?Predecease
@silvia_aut, I want to know: do I need to use mTextView.setTypeface() every time? Or it is unnecessary, because Android 4+ uses only one parent font, so can use only xml android:typeface="normal"?Sherri
To @silvia_aut. And of couse I would like to know: Do all Android 4+ devices use Roboto font? E.g. Samsung Galaxy S4 and Google Nexus 4?Sherri
M
62

You can use Roboto natively from Android 4.1+ like this:

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.

Momus answered 1/10, 2013 at 11:32 Comment(0)
S
13

Answer

Ok. I think, I got it.

Samsung phones are by far the most popular Android phones. 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. If you have fixed tight layouts with no wriggle-room that can't stretch, Samsung Sans will break them. 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.

Thx to @Ahmad as well as @Kenton Price's comment here: https://mcmap.net/q/57971/-use-roboto-font-in-app-with-minimum-api-level-14

Sherri answered 1/10, 2013 at 13:17 Comment(0)
C
4

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:

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.

Casillas answered 2/4, 2015 at 21:5 Comment(0)
D
2

From documentation:

Ice Cream Sandwich introduced a new type family named Roboto, created specifically for the requirements of UI and high-resolution screens.

Read more about Typography.

Deportment answered 1/10, 2013 at 10:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.