Change Font for Toolbar
Now, In Android, we often need to change the font-family for Toolbar as well to look more appealing UI for our end-users.
To do so we need to define the theme in our toolbar with app:theme
attribute like the below code snippet.
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="@style/AppTheme.ToolbarFont" />
Before that, we have to add the theme in our styles.xml
file and we have to define font-family in that style like the below code snippet.
<style name="AppTheme.ToolbarFont" parent="AppTheme">
<!--This line changes the color of text in Toolbar-->
<item name="android:textColorPrimary">@color/black</item>
<!--This line changes the color of icons in toolbar (back, overflow menu icons)-->
<item name="android:textColorSecondary">@color/azul</item>
<item name="textAllCaps">false</item>
<item name="android:textSize">16sp</item>
<item name="android:fontFamily">@font/montserrat_semi_bold</item>
</style>