Whenever I show a Toast
, the app crashes.
The app works fine if I use older version of AppCompat library or remove fontFamily
from the styl
According to the Android Developer Guide for fonts in xml
Adding fonts to style
Open the
styles.xml
, and set thefontFamily
attribute to the font file you want to access.<style name="customfontstyle" parent="@android:style/TextAppearance.Small"> <item name="android:fontFamily">@font/lobster</item> </style>
In your case you should put the @font/
prefix
<item name="android:fontFamily">@font/sans-serif-light</item>
Add font in Theme like below-
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="android:textViewStyle">@style/TextViewStyle</item>
<item name="android:buttonStyle">@style/ButtonStyle</item>
</style>
<style name="TextViewStyle" parent="android:Widget.TextView">
<item name="android:fontFamily">sans-serif-light</item>
</style>
<style name="ButtonStyle" parent="Widget.AppCompat.Button">
<item name="android:fontFamily">sans-serif-light</item>
</style>