Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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>
like image 961
Angelina Avatar asked May 01 '19 16:05

Angelina


People also ask

What is colorPrimary and colorPrimaryVariant?

colorPrimary and colorSecondary represent the colors of your brand. colorPrimaryVariant and colorSecondaryVariant are lighter or darker shades of your brand colors. colorSurface is used for “sheets” of material (like cards and bottom sheets) android:colorBackground is the window background color of your app.

What is attr in android?

The Attr interface represents an attribute in an Element object. Typically the allowable values for the attribute are defined in a schema associated with the document.

What is color primary variant in android?

The primary color is the color displayed most frequently across your app's screens and components. The primary variant color is used to distinguish two elements of the app using the primary color, such as the top app bar and the system bar. The secondary color provides more ways to accent and distinguish your product.


1 Answers

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

like image 161
Ola Bråten Avatar answered Nov 12 '22 19:11

Ola Bråten