Can i define two completely different colors.xml for two different themes? For example in my case we use much more different colors in pallette that defined in theme by standart(android:colorPrimary, android:colorAccent, android:colorBackground etc). Hope, that my question is clear. If it's not, ask me in comments, please.
Ok, after searching a bit I found a solution like this. Designer doesn't want to use colorPrimary etc, so I add my custom attribute in attrs like this :
<attr name="colorExperiment" format="color"/>
After this I add this attr in styles in theme like this:
<style name="DarkTheme" parent="AppTheme.NoActionBar">
<item name="android:windowAnimationStyle">@null</item>
<item name="android:windowBackground">@color/onyx</item>
<item name="colorExperiment">@color/onyx</item>
</style>
And use in layout for example:
<TextView
android:id="@+id/auth_caption"
android:includeFontPadding="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center"
android:textSize="34dp"
android:text="@string/auth_caption"
android:textColor="?colorExperiment"
/>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments