title: android pass color variable to a complex button style in XML
body: <p>I have a style for button like : <a href="http://ace-subido.github.io/css3-microsoft-metro-buttons/buttons.html" rel="nofollow">http://ace-subido.github.io/css3-microsoft-metro-buttons/buttons.html</a> (See Stripped button).
  But I want to be able to use this style for different colors without recreating 4 xml files (a selector drawable + 3 button states drawables with layer list).</p>
  
  <p>In a btn_stripped_orange.xml (and 2 other xml for different button states) I have a color </p>
  
  <p>With this syntax, evrything is ok :-)</p>
  
  <p>But instead of creating 4 new xml files for every different colors, I want to "pass a color" to btn_stripped_orange.xml (so I should rename it to btn_stripped.xml).</p>
  
  <p>In style.xml I have to call @drawable/btn_stripped_orange_selector
  after this btn_stripped_orange_selector call </p>
  
  <p>I think I have to pass the border_color variable to the style in styles.xml with call @drawable/btn_stripped_orange_selector
  I want to just create new style with the @drawable/btn_stripped_orange_selector as android:background (and rename it) and the color varaible</p>
  
  <p>This is the code that I'm trying to do (no error in eclipse, but app crash on run), If I replace ?attr/border_color with a color @color/orange for exemple, it works perfectly. I think it's just a syntax problem.</p>
  
  <p>My themes.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
     &lt;style name="btn_orange" parent="@style/btStripped1"&gt;
      &lt;item name="border_color"&gt;@attr/border_color&lt;/item&gt;
    &lt;/style&gt;
    &lt;attr name="border_color" format="color" /&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>My btn_stripped_orange_selector.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;item android:state_pressed="true" android:drawable="@drawable/btn_stripped_orange_press" /&gt;
      &lt;item android:state_focused="true" android:drawable="@drawable/btn_stripped_orange_focus" /&gt;
      &lt;item android:drawable="@drawable/btn_stripped_orange" /&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>My btn_stripped_orange.xml (nearly the same than _focus and _press) :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  &lt;item&gt;
      &lt;shape android:shape="rectangle"&gt;
          &lt;solid android:color="?attr/border_color" /&gt;
      &lt;/shape&gt;
  &lt;/item&gt;
  &lt;item android:left="5dp"&gt;
      &lt;shape android:shape="rectangle"&gt;
          &lt;solid android:color="#EEEEEE" /&gt;
      &lt;/shape&gt;
  &lt;/item&gt;
  &lt;item android:left="5dp"&gt;
      &lt;shape android:shape="rectangle"&gt;
          &lt;solid android:color="#EEEEEE" /&gt;
      &lt;/shape&gt;
  &lt;/item&gt;
  &lt;/layer-list&gt;
  </code></pre>
  
  <p>Finally in my styles.xml</p>
  
  <pre><code> &lt;resources&gt; 
     .....
      &lt;style name="btStripped1"&gt;
        &lt;!-- I want to pass a color variable here --&gt;
       &lt;item name="android:background"&gt;@drawable/btn_stripped_orange_selector&lt;/item&gt;
        &lt;item name="android:padding"&gt;6dp&lt;/item&gt;
                &lt;item name="android:textColor"&gt;@android:color/black&lt;/item&gt;
                &lt;item name="android:shadowColor"&gt;@android:color/white&lt;/item&gt;
                &lt;item name="android:shadowDx"&gt;1&lt;/item&gt;
                &lt;item name="android:shadowDy"&gt;1&lt;/item&gt;
                &lt;item name="android:shadowRadius"&gt;1&lt;/item&gt;
          &lt;/style&gt;
     ....
   &lt;/resources&gt;
  </code></pre>
  
  <p>I want a pure xml solution but if it's impossible and you have a solution with a bit of java code, your're welcome !</p>
  
  <p>Thank you very very much for your help and sorry for average english !</p>