How to reference `android:colorBackground` in XML using Material Components
Asked Answered
H

2

12

I have an app with several skins. In one skin i define android:colorBackground and then I want to set this color in an XML layout as ViewGroup background color. How do I do it? Is it possible? Or it is some attribute used by the system only?

<style name="SkinDefault" parent="@style/_SkinXYZ">
    <item name="android:colorBackground">@color/skin_default_color_background</item>
    <item name="colorOnBackground">@color/skin_default_color_on_background</item>
</style>
Hyaena answered 1/5, 2019 at 16:35 Comment(0)
A
25

Ran into this problem myself, colorOnBackground and the other Material Components colors can be referenced with ?attr/colorOnBackground. But in order to reference android:colorBackground you will have to preface with android like this ?android:attr/colorBackground

Argillite answered 12/6, 2019 at 7:44 Comment(0)
V
0

this also worked for me

android:textColor="?attr/android:colorBackground"
Visakhapatnam answered 19/8, 2022 at 10:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.