curioustechizen / android-textfontweight-issue

Repro for issue with overriding android:textFontWeight when used in a TextAppearance

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem

Let's say you use android:textFontWeight (introduced in API 28) in a TextAppearance as follows

<style name="MyTextStyle" parent="TextAppearance.AppCompat">
    <item name="android:fontFamily">@font/montserrat</item>
    <item name="android:textSize">18sp</item>
    <item name="android:textFontWeight">500</item>
</style>

Now, if you set this TextAppearance to a TextView in a layout, overriding the textFontWeight has no effect. In the following example, The "Hello world" text still renders with font weight of 500 (which was set in the TextAppearance), not 800 (which we set in the layout)

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello world"
    android:textAppearance="@style/MyTextStyle"
    android:textFontWeight="800" />

Screenshot

Screenshot

About

Repro for issue with overriding android:textFontWeight when used in a TextAppearance


Languages

Language:Kotlin 100.0%