title: Copy theme from another application
body: <p>I have an application that contains a custom theme and I wish to share it with other applications. The idea is that this application provides themes to other applications.</p>
  
  <p>The theme is defined in styles.xml as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;resources&gt;
  
  &lt;style name="Text"&gt;
      &lt;item name="android:textColor"&gt;#00FF00&lt;/item&gt;
      &lt;item name="android:textColorHighlight"&gt;#FFFF9200&lt;/item&gt;
      &lt;item name="android:textColorHint"&gt;#FFCCFF&lt;/item&gt;
      &lt;item name="android:textColorLink"&gt;#5C5CFF&lt;/item&gt;
      &lt;item name="android:textSize"&gt;16sp&lt;/item&gt;
      &lt;item name="android:textStyle"&gt;normal&lt;/item&gt;
  &lt;/style&gt;
  
  &lt;style name="Button"&gt;
      &lt;item name="android:background"&gt;#FF0000&lt;/item&gt;
      &lt;item name="android:focusable"&gt;true&lt;/item&gt;
      &lt;item name="android:clickable"&gt;true&lt;/item&gt;
      &lt;item name="android:textAppearance"&gt;?android:attr/textAppearanceSmallInverse&lt;/item&gt;
      &lt;item name="android:textColor"&gt;#FFFF00&lt;/item&gt;
      &lt;item name="android:textSize"&gt;22dip&lt;/item&gt;
      &lt;item name="android:gravity"&gt;center_vertical|center_horizontal&lt;/item&gt;
  &lt;/style&gt;
  
  &lt;style name="Theme.example" parent="android:Theme"&gt;
      &lt;item name="android:background"&gt;#FF0000&lt;/item&gt;
      &lt;item name="android:buttonStyle"&gt;@style/Button&lt;/item&gt;
      &lt;item name="android:textAppearance"&gt;@style/Text&lt;/item&gt;
  &lt;/style&gt;
  
  &lt;/resources&gt;
  </code></pre>
  
  <p>To get this theme from the second app:</p>
  
  <pre><code>Context appThemesContext = this.getApplicationContext().  
                             createPackageContext("com.appThemes", 
                                                   Context.CONTEXT_IGNORE_SECURITY);
  appThemesContext.setTheme(0x7f050002); //The resid of the desired theme
  this.getTheme().setTo(appThemesContext.getTheme()); //Copy the theme
  </code></pre>
  
  <p>The problem is that only the direct attributes like "background" are copied, the references attributes like "buttonStyle" not, because the "setTo" method says: </p>
  
  <blockquote>
    <p>Set this theme to hold the same contents as the theme other. If both of these themes are from the same Resources object, they will be identical after this function returns. If they are from different Resources, only the resources they have in common will be set in this theme.</p>
  </blockquote>
  
  <p>Does anyone know how to copy a theme from the resources of other application?? The theme won't use resources like images, etc... only values.</p>
  
  <p>Thanks ;)</p>