Note that there are some explanatory texts on larger screens.

plurals
  1. POUse theme with style, selector and attr on Android
    primarykey
    data
    text
    <p>I try to change text color with theme in a selector but i have already the same color : #fff (i havent this color in my colors.xml !)</p> <p>Here is my selector.xml (in drawable/) :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_selected="true" android:color="@android:color/white" /&gt; &lt;item android:state_focused="true" android:color="@android:color/white" /&gt; &lt;item android:state_pressed="true" android:color="@android:color/white" /&gt; &lt;item android:color="?attr/tabsTextColor" /&gt; &lt;/selector&gt; </code></pre> <p>My attrs.xml file :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;attr name="tabsTextColor" format="color" /&gt; &lt;/resources&gt; </code></pre> <p>Colors.xml file :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;!-- ... --&gt; &lt;color name="tabs_text_color"&gt;#ff0&lt;/color&gt; &lt;/resources&gt; </code></pre> <p>And my theme.xml :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;style name="Theme.Custom" parent="@style/Theme.GreenDroid.NoTitleBar"&gt; &lt;item name="tabsTextColor"&gt;@color/tabs_text_color&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre> <p>I dont understant because text color is in red (get #f00 with photoshop) but not #ff00 !</p> <p>Where is the mistake? Thanks</p> <p><strong>EDIT :</strong> I replace in my layout</p> <pre><code>android:textColor="@drawable/selector.xml" </code></pre> <p>By</p> <pre><code>android:textColor="?attr/tabsTextColor" </code></pre> <p>And the color is good ! I can't use selector with theme attr ?</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. 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