Allow styles to be themed
<p>I have a simple problem. I'd like to provide multiple themes for my UI that a user can switch between</p>

<p>The problem is that I can use a theme that styles primitive UI classes, or I can use a style directly on an XML layout element, but I can't define a style that will then change based on the theme I have applied. Not all of the styling I want to do is based on the primitive type.</p>

<p>I would say that what I want to do is similar to using a CSS selector to style a class or ID, but themes only allow you to style an element name.</p>

<hr>

<p>The best I can do right now is have a base style that inherits from EITHER of the actual styles I've built, as below:</p>

<p>My res/values/style.xml</p>

<pre><code>// All styles have to be subclassed here to be made generic, and only one
// can be displayed at a time. Essentially, I'm doing the same thing as setting
// a theme does, but for styles. If I have 50 styles, I have to have 50 of
// these for each theme, and that's not DRY at all!
&lt;style name="MyHeaderStyle" parent="MyHeaderStyle.Default"/&gt;
&lt;!--
    &lt;style name="MyHeaderStyle" parent="MyHeaderStyle.Textures"/&gt;
--&gt;

&lt;style name="MyHeaderStyle.Default"&gt;
    &lt;item name="android:background"&gt;@android:color/background_dark&lt;/item&gt;
&lt;/style&gt;

&lt;style name="MyHeaderStyle.Textures"&gt;
    &lt;item name="android:background"&gt;@drawable/header_texture&lt;/item&gt;
&lt;/style&gt;
</code></pre>

<p>Usage in my layout.xml:</p>

<pre><code>&lt;!-- Note that I can't use a theme here, because I only want to style a
     SPECIFIC element --&gt;
&lt;LinearLayout android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              style="@style/MyHeaderStyle"
              android:gravity="center"&gt;
&lt;/LinearLayout&gt;
</code></pre>
