Я использую собственный шрифт в своем приложении для Android. Я хочу установить этот пользовательский шрифт в качестве шрифта приложения по умолчанию (в качестве запасного варианта), но я все еще хочу использовать свойство TextView
textAppearance
для установки шрифта и стиля текста.
Похоже, если установить textViewStyle
или fontFamily
в базовой теме моего приложения, то allays переопределит стиль TextView
textAppearance
?
<style name="MyApp.Base" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Overriding fontFamily also overrides textView textAppearance -->
<item name="android:fontFamily">@font/open_sans</item>
<!-- Overriding textViewStyle also overrides textView textAppearance -->
<item name="android:textViewStyle">@style/DefaultTextAppearance</item>
</style>
<style name="DefaultTextAppearance" parent="TextAppearance.AppCompat">
<item name="android:textStyle">normal</item>
<item name="fontFamily">@font/open_sans_regular</item>
</style>
<style name="BoldTextAppearance" parent="TextAppearance.AppCompat">
<item name="android:textStyle">normal</item>
<item name="fontFamily">@font/open_sans_extra_bold</item>
</style>
<!-- This textView does not get bold style -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Me happy"
android:textAppearance="@style/BoldTextAppearance" />