I'm trying to change some colors of the components of my application by setting a custom theme for day mode and night mode, like this:
in values/styles.xml (day mode):
<resources>
<!-- Base application theme. -->
<style name="MyTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
...
</resources>
Same file in values/styles.xml (night)
I want to change the color of some parts of the UI (seekbar bar, toolbar, action bar title, floating buttons etc.) but I don't know which color corresponds to each element and I'm kinda going crazy googling here and there for tricky solutions for any component I need to change the color too. Is there any guideline or good visual example on where to check all of this? For instance, right now it's taking a long time for me to figure out how to change the popupmenu background or the actionbar menu background since there's no attributes in the menu files. I'm new to android development so any kind of guidance regarding this would be very welcomed.
You used
Theme.MaterialComponents.DayNight....whereDayNightis more of a adaptive dynamic theme which changes to material design default color. If you need more control to color and styles, do as follows:Your
Daytheme insidevalues/styles.xmlshould extend fromTheme.MaterialComponents.Light.DarkActionBarYour
Nighttheme insidevalues-night/styles.xmlshould extend fromTheme.MaterialComponentsas it is well-suited for the Dark Mode.Regarding this, if you want app-wide changes then you can follow this method of styling(almost all views styling can be done this way):
If you want to style each for eg.
ToolBardifferently, you can usestyle="@style/MyToolBarStyle"attributes in your layout files to give each of them differentshape,colourand other material effects as you want.About Colors: Normally, you can play with these colour attributes in your
styles.xmlto change the complete look and feel of your app.Important Links: