Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The error message I get for this is:</p> <pre><code>org.xmlpull.v1.XmlPullParserException: Binary XML file line #18: &lt;item&gt; tag requires a 'drawable' attribute or child tag defining a drawable </code></pre> <p>Doing a little digging, the specs say the <code>background</code> attribute should support either a colour, or reference to a drawable resource:</p> <p>... Looking at the resource you're referencing, it <em>is</em> a <code>StateListDrawable</code>.</p> <pre><code>platforms/android-17/data/res/color/primary_text_dark.xml &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_enabled="false" android:color="@android:color/bright_foreground_dark_disabled"/&gt; &lt;item android:state_window_focused="false" android:color="@android:color/bright_foreground_dark"/&gt; &lt;item android:state_pressed="true" android:color="@android:color/bright_foreground_dark_inverse"/&gt; &lt;item android:state_selected="true" android:color="@android:color/bright_foreground_dark_inverse"/&gt; &lt;item android:state_activated="true" android:color="@android:color/bright_foreground_dark_inverse"/&gt; &lt;item android:color="@android:color/bright_foreground_dark"/&gt; &lt;!-- not selected --&gt; &lt;/selector&gt; </code></pre> <p>However, the docs for StateListDrawable also explicitly say the <code>drawable</code> attribute must be defined for <code>item</code> elements:</p> <pre><code>https://developer.android.com/guide/topics/resources/drawable-resource.html &lt;item&gt; Defines a drawable to use during certain states, as described by its attributes. Must be a child of a &lt;selector&gt; element. attributes: android:drawable Drawable resource. Required. Reference to a drawable resource. </code></pre> <p>... which isn't the case for the case for <code>primary_text_dark.xml</code>. So, it's not working because the drawable you're referencing doesn't seem to conform to the spec.</p> <p>I think the workaround is to reference the colour that's used in <code>primary_text_dark</code> for the default state: <code>bright_foreground_dark</code>. Seeing as that's not public, you need to go directly to the one it references, which is:</p> <pre><code>android:background="@android:color/background_light" </code></pre>
 

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