title: Is it possible to reference attributes from styles.xml file?
body: <p>I want to give the user the possibility to switch the colors skin of my entire application. I mean to switch the style of some custom views of the app dynamically when the user presses a button of the screen. I know that if you call <code>Activity.setTheme()</code> before <code>onCreate()</code> method, you can change the theme of the app dynamically, but normal Views (for example, <code>NavigationView</code>) with custom styles applied on their xml layout, do not have setTheme or setStyle methods, so it is does not appear possible to change their style dynamically.</p>
  
  <p>I think that my objective would be possible referencing colors declared in an AppTheme declared inside <code>styles.xml</code> file. I mean, i can have two AppThemes declared, each one with one set of colors, and then, in the custom styles declared for the custom views, reference the colors. Something like this:</p>
  
  <pre><code>&lt;resources&gt;
      &lt;style name="AppTheme" parent="Theme.AppCompat"&gt;
          &lt;item name="customColor"&gt;#111111&lt;/item&gt;
      &lt;/style&gt;
  
      &lt;style name="AppTheme.AnotherColor" parent="Theme.AppCompat"&gt;
          &lt;item name="customColor"&gt;#222222&lt;/item&gt;
      &lt;/style&gt;
  
      &lt;style name="CustomActionBar"&gt;
          &lt;!-- title text color --&gt;
          &lt;item name="android:textColorPrimary"&gt;@styles/customColor&lt;/item&gt;
      &lt;/style&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>So, by default, the custom Color declared on my "AppTheme" will be applied by default, using color <code>111111</code>. But when I change the theme of my app using <code>setTheme(R.styles.AppTheme_AnotherColor)</code> the color applied will be <code>222222</code>. If this would be possible it would be perfect! but it is not possible or I don't know how to access to a color declared inside a style directly from another style of the same <code>styles.xml</code> file. I mean that <code>@styles/customColor</code> is not correct and I don't know how to access that color.</p>
  
  <p>How can this be achieved?</p>