Reputation: 344
I know I might be making more than enough mistakes here. But do lemme know. I've tried going through MaterialIO documentation the best way I can, and it all looks so spun up and complicated with a dozen links in each page redirecting me to another minor component. That's when I decided to TRY it.
<application ...
android:theme="@style/Theme.MaterialComponents.DayNight" >
</application>
values/themes.xml
and values-night/themes.xml
as instructed by some part of the material IO page.android:
to some tags and some tags raised errors when I did.<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppCompat.." parent="Theme.MaterialComponents.DayNight">
<item name="android:colorBackground">@color/JDBG</item>
<item name="colorSurface">@color/JDSurface</item>
<item name="colorPrimary">@color/JDPrimary</item>
<item name="android:colorSecondary">@color/JDSecondary</item>
<item name="android:OnBackground">@color/JDOnBackground</item>
<item name="android:OnSurface">@color/JDOnSurface</item>
<item name="OnPrimary">@color/JDOnPrimary</item>
<item name="OnSecondary">@color/JDOnSecondary</item>
</style>
</resources>
colors.xml
and colors-night.xml
files, which told me that those values didn't have a declaration in the base values folder and it might raise issues.I do not want to toil at nothing with very abstract documentation that leads me on ten directions at every point. Hence the question . . . Is there anything wrong I've done ? What do I do next ?
Upvotes: 0
Views: 653
Reputation: 363935
Just define your theme in a resources file.
For example res/values/styles.xml
:
<style name="MyTheme" parent="Theme.MaterialComponents.DayNight">
<item name="colorPrimary">@color/....</item>
<item name="colorSecondary">@color/....</item>
<item name="colorOnPrimary">@color/....</item>
<item name="colorOnSecondary">@color/....</item>
.....
</style>
Define the colors in res/values/colors.xml
and res/values-night/colors.xml
.
Then apply the theme in the Manifest:
<application ...
android:theme="@style/MyTheme" >
Check also the official guide.
Upvotes: 1