Reputation: 618
I am following the Typography guide and this link
How to change fontFamily of TextView in Android
It says sans-serif-medium is available on Android 4.1 / 4.2 / 5.0.
But when I try to find these font types, I can't seem to find the suggestion. Why??
Do i have to download ttf files for this font??
My complied SDK is 24.
Upvotes: 3
Views: 2828
Reputation: 2455
Do like this to use Sans Serif font.
In your styles.xml files, define style for font
<style name="roboto_regular_textview" parent="@android:style/Widget.TextView">
<item name="android:fontFamily">sans-serif</item>
</style>
<style name="roboto_medium_textview" parent="@android:style/Widget.TextView">
<item name="android:fontFamily">sans-serif</item>
<item name="android:textStyle">bold</item>
</style>
<style name="roboto_light_textview" parent="@android:style/Widget.TextView">
<item name="android:fontFamily">sans-serif-light</item>
</style>
And in layout.xml file
<TextView
style="@style/roboto_regular_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/black_text_color"
android:textSize="30sp" />
Upvotes: 2