title: How to reference style attributes from a drawable?
body: <p>I want to have 2 selectable themes for my application. In order to do that, I defined some attributes, like this:</p>
  
  <pre><code> &lt;attr format="color" name="item_background" /&gt;
  </code></pre>
  
  <p>Then, I created both themes, like this:</p>
  
  <pre><code>  &lt;style name="ThemeA"&gt;
       &lt;item name="item_background"&gt;#123456&lt;/item&gt;
   &lt;/style&gt;
  
   &lt;style name="ThemeB"&gt;
       &lt;item name="item_background"&gt;#ABCDEF&lt;/item&gt;
   &lt;/style&gt;
  </code></pre>
  
  <p>This method works great, allowing me to create and modify several themes easily. The problem is that <strong>it seems that it can be used only in Views, and not in Drawables</strong>.</p>
  
  <p>For example, referencing a value from a View inside a layout works:</p>
  
  <pre><code> &lt;TextView android:background="?item_background" /&gt;
  </code></pre>
  
  <p>But doing the same in a Drawable doesn't:</p>
  
  <pre><code> &lt;shape android:shape="rectangle"&gt;
       &lt;solid android:color="?item_background" /&gt;
   &lt;/shape&gt;
  </code></pre>
  
  <p>I get this error when running the application:</p>
  
  <pre><code>    java.lang.UnsupportedOperationException: Can't convert to color: type=0x2
  </code></pre>
  
  <p>If instead of <code>?item_background</code> I use a hardcoded color, it works, but that doesn't allow me to use my themes. I also tried <code>?attr:item_background</code>, but the same happens.</p>
  
  <p>How could I do this? And why does it work in Views but not in Drawables? I can't find this limitation anywhere in <a href="http://developer.android.com/guide/topics/resources/accessing-resources.html#ReferencesToThemeAttributes" rel="noreferrer">the documentation</a>...</p>