Posts like this How to change fontFamily of TextView in Android suggests, that the variants of Roboto fonts you can specify in styles.xml in Android 4.2 boils down to the following:
That leaves out the ability to style TextViews using eg. the Roboto-Medium or Roboto-Black fonts.
But why would Google add system wide fonts that can not be used for styling of your TextViews? Surely there must be some way of specifying all of the Roboto fonts from within styles.xml (ie. NOT having to embed the fonts as Assets and creating custom TextViews in code) - but how?
Arial, Helvetica, sans-serif.
Roboto (/roʊˈbɒt. oʊ/) is a neo-grotesque sans-serif typeface family developed by Google as the system font for its mobile operating system Android, and released in 2011 for Android 4.0 "Ice Cream Sandwich".
On Android 5.0 you can set Roboto Medium with sans-serif-medium
.
This solution, taken from Google iosched 2014, uses sans-serif
on Android pre-v21:
values/styles.xml
<style name="MyStyle"> <item name="android:fontFamily">@string/font_fontFamily_medium</item> </style>
values/fonts.xml
<string name="font_fontFamily_medium">sans-serif</string>
values-v21/fonts.xml
<string name="font_fontFamily_medium">sans-serif-medium</string>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With