Valid values for android:fontFamily and what they map to?

In the answer to this question the user lists values for android:fontFamily and 12 variants (see below). Where do these values come from? The documentation for android:fontFamily does not list this information in any place (I checked here, and here). The strings are listed in the Android styles.xml file in various places, but how do these map back to the Roboto font?

From android 4.1 / 4.2, the following Roboto font families are
available:

android:fontFamily="sans-serif"           // roboto regular  
android:fontFamily="sans-serif-light"     // roboto light  
android:fontFamily="sans-serif-condensed" // roboto condensed  
android:fontFamily="sans-serif-thin"      // roboto thin (android 4.2)  
android:fontFamily="sans-serif-medium"    // roboto medium (android 5.0)

in combination with this

android:textStyle="normal|bold|italic" 

12 variants are possible:

  • Regular
  • Italic
  • Bold
  • Bold-italic
  • Light
  • Light-italic
  • Thin
  • Thin-italic
  • Condensed regular
  • Condensed italic
  • Condensed bold
  • Condensed bold-italic

In the styles.xml file in the application I’m working on somebody listed this as the font family, and I’m pretty sure it’s wrong:

<item name="android:fontFamily">Roboto-Regular.ttf</item>

I’d like to get the theme for our app set up correctly (which includes using fontFamily correctly) and remove all the redundancy that is in some of the styles that were created before I had a look at the file.

3 Answers
3

Leave a Comment