title: Getting default TextView textColor in Android for current Theme
body: <p>I'm trying to reset the TextColor of a TextView at runtime. I would like to get the default color for TextView as a <code>@ColorInt</code>. I believe that the current Theme knows this.</p>
  
  <p>Here's what I tried:</p>
  
  <pre><code>public @ColorInt int getDefaultThemeColor(int attribute) {
      TypedArray themeArray = mContext.getTheme().obtainStyledAttributes(new int[] {attribute});
      try {
          int index = 0;
          int defaultColourValue = 0;
          return themeArray.getColor(index, defaultColourValue);
      }
      finally {
          themeArray.recycle();
      }
  }
  </code></pre>
  
  <p>where attribute is:</p>
  
  <ul>
  <li><code>android.R.attr.textColor</code></li>
  <li><code>android.R.attr.textColorPrimary</code></li>
  <li><code>android.R.attr.textColorSecondary</code></li>
  </ul>
  
  <p>None of them worked to retrieve the right color. I've also tried to replace the first line of the method with:</p>
  
  <pre><code>TypedArray themeArray = mContext.getTheme().obtainStyledAttributes(R.style.AppTheme, new int[] {attribute});
  </code></pre>
  
  <p>I don't want the dirty solution of:</p>
  
  <ol>
  <li>getting and storing the textColor of a TextView</li>
  <li>changing the color to whatever</li>
  <li>Reset it back to the previously stored value</li>
  </ol>
  
  <p>Any hint?</p>