Stack Overflow archive
2 scoreaccepted

Have Custom Style Change Based On My AppTheme Style Selection

score
2
question views
311
license
CC BY-SA 3.0

This should work (did not test):

attrs.xml

xml
<resources>
        <attr name="customViewBackground" format="reference" />
</resources>

styles.xml

xml
<style name="MyCustomViewBackground">
    ...
    <item name="android:background">?attr/customViewBackground</item>
    ...
</style>

themes.xml

xml
<style name="AppTheme.Light" parent="@android:style/Theme.Holo.Light">
    ...
    <item name="customViewBackground">@drawable/half_alpha_white_rounded_background</item>
    ...
</style>

<style name="AppTheme.Dark" parent="@android:style/Theme.Holo.Dark">
    ...
    <item name="customViewBackground">@drawable/half_alpha_dark_rounded_background</item>
    ...
</style>

Originally posted on Stack Overflow. Public user contributions are licensed under Creative Commons Attribution-ShareAlike.