When creating a new app using the wizard of Android Studio a theme derived from Theme.MaterialComponents.Light.DarkActionBar
is used and a colorAccent
is set. On the other side the official documentation uses colorSecondary
and doesn't mention colorAccent
at all. Are both interchangeable? What to prefer?
This answer is not useful. Show activity on this post. Yes, I do believe colorSecondary is the new term for colorAccent and are interchangeable because if you read the docs specifically the definition of secondary color it says. A secondary color provides more ways to accent and distinguish your product.
onSecondary. Color used for text and icons displayed on top of the secondary color. Color. onSurface. Color used for text and icons displayed on top of the surface color.
A Material theme includes color, typography and shape parameters which you can adjust to get near-infinite variations of the components – all while maintaining their core anatomy and usability. On Android, Material Theming can be implemented using the Material Components (MDC) library, from version 1.1. 0 onwards.
The Theme.MaterialComponents
uses the colorSecondary
as described in the material guidelines and in the official doc.
All the components defined in the library uses this attribute.
However, in the library, there are also the Bridge
themes which inherit from AppCompat
themes and you can use them, if you cannot change your theme to inherit from a Material Components theme.
These themes inherit from AppCompat
themes defining the new Material Components theme attributes for you.
You can check the bridge theme in the library:
<style name="Base.V14.Theme.MaterialComponents.Light" parent="Base.V14.Theme.MaterialComponents.Light.Bridge">
<!-- Colors -->
<item name="colorAccent">?attr/colorSecondary</item>
Here you can find the mapping between colorSecondary
and the colorAccent
for these themes.
Yes, I do believe colorSecondary
is the new term for colorAccent
and are interchangeable because if you read the docs specifically the definition of secondary color it says
A secondary color provides more ways to accent and distinguish your product. Having a secondary color is optional, and should be applied sparingly to accent select parts of your UI.
I guess just from that statement it is pretty clear that they both have the same purpose.
As per the material design documentation, the primary color and the secondary color are actually the primaryColor and accentColor in Android Studio. But if more variations are required then the secondaryColor can be used.
So prefer accentColor tag in Android Studio to define the secondary color from material design documentation.
You can try out some material palettes like https://www.materialpalette.com to understand the behaviour.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With