I have the code:
val color = if(...)
android.R.color.darker_gray
else
android.R.color.secondary_text_dark
The value android.R.color.secondary_text_dark
is now deprecated in API level 28, it says "Use a text color from your theme instead.". There is a listed constant value and a bracket " 17170437 (0x01060005)", but I cannot understand these these color values as they cannot be put in colors.xml
because color hex values should be in the format such as "#ffxxxx"
.
Can someone tell me what are the meaning of those constant numbers? Is there a different treatment to text color from usual colors? If I want to maintain the same behaviour, how should I extract those color values?
After digging further, I realized that android.R.color.secondary_text_dark
is actually not a color value, but rather a selector itself in the file name of secondary_text_dark.xml
:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="false" android:color="@android:color/dim_foreground_dark_disabled"/>
<item android:state_window_focused="false" android:color="@android:color/dim_foreground_dark"/>
<item android:state_selected="true" android:state_enabled="false" android:color="@android:color/dim_foreground_dark_inverse_disabled"/>
<item android:state_pressed="true" android:state_enabled="false" android:color="@android:color/dim_foreground_dark_inverse_disabled"/>
<item android:state_selected="true" android:color="@android:color/dim_foreground_dark_inverse"/>
<item android:state_activated="true" android:color="@android:color/bright_foreground_dark_inverse"/>
<item android:state_pressed="true" android:color="@android:color/dim_foreground_dark_inverse"/>
<item android:state_enabled="false" android:color="@android:color/dim_foreground_dark_disabled"/>
<item android:color="@android:color/dim_foreground_dark"/>
</selector>
With that, I can copy its content into my res/animator
folder, extract all the color values it refers to, and call R.animator.secondary_text_dark
from my code.