1

I don't want to customise my fonts.I just want to use the fonts available in android studio.How do i change the font of my text to sans or serif or monospace?

2 Answers2

1

-Hello as per this Stackoverflow answer

-android:typeface is used in xml for changing the fonts.

-You final code would be:-

<Textview .......... =android:typeface="normal/sans/monospace"..../>
Community
  • 1
  • 1
Hardy
  • 2,576
  • 1
  • 23
  • 45
0

If you want to change the font for the whole app then I will recommend to use the styles for this.

Just add the following line to your styles.xml file -

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:textViewStyle">@style/TextAppearance.Sans</item>
    <item name="android:buttonStyle">@style/TextAppearance.Sans</item>
</style>

<style name="TextAppearance.Sans" parent="TextAppearance.AppCompat.Large">
        <item name="android:fontFamily">sans-serif-light</item>
        <item name="android:textStyle">normal</item>
</style>

If you don't want to change the font through out the app then instead of setting in AppTheme just simply define the style element in each TextView you want to change the font for -

<TextView
    style="@style/TextAppearance.Sans"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>
Varundroid
  • 9,135
  • 14
  • 63
  • 93