I have a project and in this project I have defined fontFamily to all textviews in the style of AppTheme.
The fontFamily is montserrat
but in text views I use montserrat_semibold
, montserrat_regular
and montserrat_medium
.
<style name="AppTheme" parent="Theme.MaterialComponents.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:textViewStyle">@style/MontserratTextViewStyle</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="MontserratTextViewStyle" parent="android:Widget.TextView">
<item name="android:fontFamily">@font/montserrat</item>
</style>
How can I change their weight in the different XMLs of textviews?
Hmm the only way I can think of doing that is to create multiple styles in your
styles.xml
:Then for any
TextView
which doesn't use the defaultmontserrat
i.e. maybe you wantmontserrat_medium
: