This can either be declared as a dimen as we have in or as a percentage value as we have done in the other two shape appearances. The first is cornerSize which specifies the size of the corners. So in ShapeAppearanceOverlay.Pill we override two attributes without affecting the active theme. So if we define our own ThemeOverlay we can be sure that we’re overriding only the specific attribute that we declare within our custom style, whilst allowing the active theme behaviour the apply. The ThemeOverlay mechanism is a key part of how things like defining colorPrimary in the theme ripple down to the child views – the Themes & Styles defined by Material Components use this technique quite heavily. a style with an empty parent) then it will use the colours defined in the current Activity theme, and it will fit in with the colour scheme of the current Activity. If we apply a theme overlay instead (i.e. If we apply a style with an explicit parent set, and colours defined within that parent will override the Activity theme. In other words we might have two Activities and each has a different theme applied – perhaps one has a light theme and the other has a dark theme. When we specify no parent, then the style will overlay whatever theme is being applied. Normally when we define a style, we would provide a parent style, and then we can override specific attributes to alter specific parts of that style. On the face of it, that does not appear to do much, but looks are deceptive! The key to the overlay behaviour is the empty parent attribute – this is what causes the overlay behaviour.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |