Is this a confirmation that I cannot use the thematic color attribute in the resource of the list of color states

Is this a confirmation that I can not use the thematic color attribute in the resource of the list of color states ?

I have the following code that works very well.

color / home _menu_text_view_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:color="#ffffffff" />    <!-- pressed -->
    <item android:state_focused="true" android:color="#ffffffff" />    <!-- focused -->
    <item android:state_selected="true" android:color="#ffffffff" />   <!-- selected -->
    <item android:color="#ff000000" />                                 <!-- default -->
</selector>

Layout / home _menu_row.xml

<!-- Use duplicateParentState, so that we can receive click event from parent linear layout -->
<TextView
    android:id="@+id/name"
    android:gravity="center_vertical"
    android:padding="5dp"
    android:layout_width="0dp"
    android:layout_weight="1"
    android:layout_height="48dp"
    android:duplicateParentState="true"        
    android:textColor="@color/home_menu_text_view_selector"
    android:drawablePadding="10dp" />

However, if I configure the code for the following, it no longer works. When in default mode, it no longer changes to my desired color. ?android:attr/textColorPrimarysuppose it is black (# ff000000) in my case.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:color="#ffffffff" />    <!-- pressed -->
    <item android:state_focused="true" android:color="#ffffffff" />    <!-- focused -->
    <item android:state_selected="true" android:color="#ffffffff" />   <!-- selected -->
    <item android:color="?android:attr/textColorPrimary" />            <!-- default -->
</selector>

- , ? , . .:)

+5
1

FYI, , API 23. . -

, , , Android, , , , , .

Android Attribute (attr) Android Color . , attr , .

attr , , , , .. - , - style.

: ImageView , src, LinearLayout , . "" ImageView , , , , fitXY, ImageView.

selector , , attr color, android: , attr , .

: attr , , , , attr, attr . p >

+1

All Articles