title: Android attributes,declare-styleable,reference
body: <p>I am newbie in android development, I am trying to create my custom view right now. I have faced with a lot of problems. I have solved some of them, but the most difficult to understand for is attributes.
  Let's take sample xml file with attributes </p>
  
  <pre><code>&lt;declare-styleable name="ViewPagerIndicator"&gt;
          &lt;!-- Style of the circle indicator. --&gt;
          &lt;attr name="vpiCirclePageIndicatorStyle" format="reference"/&gt;
          &lt;!-- Style of the icon indicator's views. --&gt;
          &lt;attr name="vpiIconPageIndicatorStyle" format="reference"/&gt;
          &lt;!-- Style of the line indicator. --&gt;
          &lt;attr name="vpiLinePageIndicatorStyle" format="reference"/&gt;
          &lt;!-- Style of the title indicator. --&gt;
          &lt;attr name="vpiTitlePageIndicatorStyle" format="reference"/&gt;
          &lt;!-- Style of the tab indicator's tabs. --&gt;
          &lt;attr name="vpiTabPageIndicatorStyle" format="reference"/&gt;
          &lt;!-- Style of the underline indicator. --&gt;
          &lt;attr name="vpiUnderlinePageIndicatorStyle" format="reference"/&gt;
      &lt;/declare-styleable&gt;
      &lt;attr name="centered" format="boolean" /&gt;
      &lt;attr name="selectedColor" format="color" /&gt;
      &lt;attr name="strokeWidth" format="dimension" /&gt;
      &lt;attr name="unselectedColor" format="color" /&gt;
  
      &lt;declare-styleable name="CirclePageIndicator"&gt;
          &lt;attr name="centered" /&gt;
          &lt;attr name="fillColor" format="color" /&gt;
          &lt;attr name="pageColor" format="color" /&gt;
          &lt;attr name="android:orientation"/&gt;
          &lt;attr name="radius" format="dimension" /&gt;
          &lt;attr name="snap" format="boolean" /&gt;
          &lt;attr name="strokeColor" format="color" /&gt;
          &lt;attr name="strokeWidth" /&gt;
          &lt;attr name="android:background"/&gt;
      &lt;/declare-styleable&gt;
  &lt;declare-styleable name="LinePageIndicator"&gt;
      &lt;attr name="centered" /&gt;
      &lt;attr name="unselectedColor" /&gt;
      &lt;attr name="selectedColor" /&gt;
      &lt;attr name="lineWidth" format="dimension" /&gt;
      &lt;attr name="strokeWidth" /&gt;
      &lt;attr name="gapWidth" format="dimension" /&gt;
      &lt;attr name="android:background"/&gt;
  &lt;/declare-styleable&gt;
  </code></pre>
  
  <ol>
  <li>What does reference format mean, I cannot still understand what does this format mean, what I've found that it can be used with drawables also I seen that can be used with themes. Please give good example where it can be useful and what is the main purpose of this format type. In preceding example it is used for style, but I don't understand how can I use this in my xml file where I am going to use custom view.</li>
  </ol>
  
  <blockquote>
  <pre><code>   &lt;com.viewpagerindicator.CirclePageIndicator
          android:id="@+id/indicator"
          android:padding="10dip"
          android:layout_height="wrap_content"
          android:layout_width="wrap_content"
          custom:auto_cycle="true"
      custom:pageColor="@color/abc_background_cache_hint_selector_material_dark"
          /&gt;
  </code></pre>
  </blockquote>
  
  <ol start="2">
  <li><p>Each <code>declare-styleable name="Name of custom view"</code> line, as I can understand, used for separate custom view, we can see this in the example. But what is the purpose of <code>&lt;declare-styleable name="ViewPagerIndicator"&gt;</code>, I haven't found any view in this lib with such name and this stylable is include my first question (reference attribute). </p></li>
  <li><p>If attribute declared out of declare-stylable it means that it is in several view and not to duplicate code in each view common attributes are placed outside. Am I right ? </p></li>
  </ol>
  
  <p>Please help, I have spent a day trying to find any tutorials or documentation. Official documentation is very poor. I think a lot of newbies will be grateful for explaining this topic.</p>
  
  <p>Please help to understand this, the most important question is about references (first qustion)   <code>&lt;attr name="vpiCirclePageIndicatorStyle" format="reference"/&gt;</code> what is this , how to use this, where it is declared ?</p>
  
  <p>Also I found another example used in another lib</p>
  
  <pre><code>&lt;declare-styleable name="Themes"&gt;
      &lt;attr name="SliderStyle" format="reference"/&gt;
      &lt;attr name="PagerIndicatorStyle" format="reference"/&gt;
  &lt;/declare-styleable&gt;
  </code></pre>
  
  <p>I cannot understand this at all. Please help, you are my last hope.</p>