mirror of
https://github.com/material-components/material-components-android.git
synced 2026-02-04 19:48:23 +08:00
android:textAllCaps="true" in the layout xml is being ignored because:
1) A known issue where Chip only reads from its textappearance. However, even after creating a custom textappearance that sets textAllCaps to true, I'm observing an odd behavior:
if I comment out the setSingleLine method call in the constructor, then the text becomes all caps. If I comment setSingleLine back in and call setAllCaps, then the text becomes capitalized and single line.
I think it's related to two different transformation methods being applied. The one inside setsingleline clobbers the one set by setAllCaps.
TextView's constructor applies the singleLine transformation before applying text appearance attributes
https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/widget/TextView.java#L1570-L1609
https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/widget/TextView.java#L10232
2) The library implementation of TextAppearance reads from "textAllCaps" instead of "android:textAllCaps".
11c57abbd6/lib/java/com/google/android/material/resources/TextAppearance.java (L96)
However, if you call Chip#setTextAppearance(@StyleRes int id) which passes it the super method, then "android:textAllCaps" needs to be set because "textAllCaps" is ignored
::sigh::
PiperOrigin-RevId: 283621202