I have a button and I want to set a custom font to the text but I have trouble doing that.
The code is the following :
In .xml file :
<Button
android:id="@+id/button"
style="@style/ButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Sample Text"/>
and in styles.xml
<style name="ButtonStyle" parent="@style/Widget.AppCompat.Button.Borderless">
<item name="android:textSize">@dimen/button_text_size</item>
<item name="android:background">@drawable/button_background</item>
<item name="android:textAppearanceButton">@style/ButtonTextStyle</item>
<item name="android:textColor">?android:textColorPrimaryInverse</item>
</style>
<style name="ButtonTextStyle" parent="TextAppearance.AppCompat">
<item name="android:fontFamily">@font/my_custom_font</item>
</style>
setTypefaceon your button