title: How to get a dimension value that is a reference to an attribute?
body: <p>I've got these two items in my dimension definitions:</p>
  
  <pre><code>&lt;dimen name="toolbar_search_extended_height"&gt;158dp&lt;/dimen&gt;
  &lt;dimen name="toolbar_search_normal_height"&gt;?attr/actionBarSize&lt;/dimen&gt;
  </code></pre>
  
  <p>Now I'd like to get the actual value in pixels at runtime:</p>
  
  <pre><code>height = getResources().getDimensionPixelOffset(R.dimen.toolbar_search_extended_height);
  height = getResources().getDimensionPixelOffset(R.dimen.toolbar_search_normal_height);
  </code></pre>
  
  <p>The first call gives whatever 158dp is in pixels on the device.<br>
  The second call yields a <code>NotFoundException</code>:</p>
  
  <pre><code>android.content.res.Resources$NotFoundException: Resource ID #0x7f080032 type #0x2 is not valid
  </code></pre>
  
  <p>Type <code>0x2</code> is: <code>TypedValue#TYPE_ATTRIBUTE</code>:</p>
  
  <pre><code>/** The &lt;var&gt;data&lt;/var&gt; field holds an attribute resource
   *  identifier (referencing an attribute in the current theme
   *  style, not a resource entry). */
  public static final int TYPE_ATTRIBUTE = 0x02;
  </code></pre>
  
  <p>What is the preferred method to dereference <code>dimen</code> values that can be either actual values or references to styled attributes?</p>