Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>About styleable attributes</h2> <p>In addition to being able to change that value without touching Java code, it allows them to apply different styles to their app depending on device configuration. Instead of declaring in XML:</p> <pre><code>&lt;com.example.android.snake.SnakeView android:id="@+id/snake" android:layout_width="match_parent" android:layout_height="match_parent" tileSize="24" /&gt; </code></pre> <p>they can declare these values in <code>res/values/styles.xml</code>:</p> <pre><code>&lt;style name="Control.SnakeViewStyle"&gt; &lt;item name="android:layout_width"&gt;match_parent&lt;/item&gt; &lt;item name="android:layout_height"&gt;match_parent&lt;/item&gt; &lt;item name="tileSize"&gt;24&lt;/item&gt; &lt;/style&gt; </code></pre> <p>and then refer to that style:</p> <pre><code>&lt;com.example.android.snake.SnakeView android:id="@+id/snake" style="@styles/SnakeViewStyle" /&gt; </code></pre> <p>After separating styles like this they can provide different <code>styles.xml</code> file for each device configuration. For example, there might be one <code>res/values/styles.xml</code> for portrait mode and one <code>res/values-land/styles.xml</code> for landscape mode.</p> <h2>About resources and integers</h2> <p>If a styleable attribute is declared as "reference" instead of "integer", you would (1) get IDE content assist when writing XML for that attribute and (2) compiler would check that you haven't provided a reference to non-existing resource. Consequently, to get it you need to use <code>getResourceId</code>, because it may do some additional resolving to get actual resource id.</p> <h2>About recycle</h2> <p>I'm not really sure, but judging by the code of <code>TypedArray</code>, it seems that there's some caching mechanism inside it, and <code>recycle()</code> makes it work.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload