Commit e3be6b0
committed
Support setting textAllCaps in textAppearance xml, switch from calling setSingleLine to setLines(1) so the transformation methods don't replace each other.
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".
https://github.com/material-components/material-components-android/blob/11c57abbd6b11829f49bbeafee4153e5442b2725/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: 2836212021 parent acd10e6 commit e3be6b0
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
| 229 | + | |
| 230 | + | |
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
| |||
0 commit comments