'Android themes.xml colors depending on each other

I have a question that I hope someone can help me with, let's say I have a colorAccent defined in my themes.xml file and I want the colorPrimary to depend on that colorAccent without again specifying the color in the value, so like if there are changes man can change one color and everything will change automatically, how can I achieve this?

<resources xmlns:tools="http://schemas.android.com/tools">
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
        <item name="colorPrimary">???</item>
        <item name="colorAccent">#FF0000</item>
    </style>
</resources>

And if it is possible can we do the same thing but with a color defined under colors.xml, which means the color in this file will depend on the colorAccent already defined in themes.xml ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source