title: How to read custom dimension attribute from java code
body: <p>I made my custom component just putting few TextViews together. Now I want to be able to init my custom control directly from code, passing text sizes independently for each of of TV's</p>
  
  <p>My attributes definition:</p>
  
  <pre><code>&lt;resources&gt;
      &lt;declare-styleable name="BasicGauge"&gt;
          &lt;attr name="valueTextSize" format="dimension" /&gt;
          &lt;attr name="titleTextSize" format="dimension" /&gt;
          &lt;attr name="unitsTextSize" format="dimension" /&gt;
      &lt;/declare-styleable&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>Sample initialization of component:</p>
  
  <pre><code>&lt;pl.com.digita.BikeComputerUi.customviews.BasicGauge
      android:id="@+id/basicGauge1"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:padding="10dp"
      valueTextSize="40sp"&gt;
  
  &lt;/pl.com.digita.BikeComputerUi.customviews.BasicGauge&gt;
  </code></pre>
  
  <p>How I try to read those attributes in component's constructor:</p>
  
  <pre><code>final int N = typedArray.getIndexCount();
  for (int i = 0; i &lt; N; i++) {
      int attribute = typedArray.getIndex(i);
      switch (attribute) {
          case R.styleable.BasicGauge_valueTextSize:
              valueTextSize = typedArray.getString(attribute);
              break;
          case R.styleable.BasicGauge_titleTextSize:
              titleTextSize = typedArray.getString(attribute);
              break;
          case R.styleable.BasicGauge_unitsTextSize:
              unitsTextSize = typedArray.getString(attribute);
              break;
      }
      typedArray.recycle();
  }
  </code></pre>
  
  <p><strong>Problem:</strong>
  After creation all of my values are still null. <strong>40sp</strong> is exactly my desired value.</p>