I am relatively new to using a selector for modifying properties for states such as enabled/disabled, etc. I have learned to use them for direct properties (such as textColor, background, etc.) in the layout files (such as activity_main.xml) & in styles (in styles.xml), but for things such as nested drawables I am not quite sure what to do. For example, I have a Button whose background is a layer-list drawable, and one of the drawables in that layer-list is a VectorDrawable, which has a path whose fillColor I need to change based on the enabled state of my Button. How do I do this?
I'm not sure what I was doing wrong before or why I didn't think it would work (I'm still very new to drawables & selectors), but here it is now and it works:
IncDecButtonBackground.xml:
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<shape android:shape="rectangle">
<solid android:color="@color/Silver"/>
<stroke android:width="2dp" android:color="@color/Black"/>
<corners android:radius="0dp"/>
</shape>
</item>
<item android:gravity="fill" android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp">
<vector android:width="30dp" android:height="30dp" android:viewportWidth="30" android:viewportHeight="30">
<path android:pathData="M0 0L30 0L15 30Z" android:fillColor="@drawable/incdecbuttonarrowcolorselector"/>
</vector>
</item>
</layer-list>
IncDecButtonArrowColorSelector.xml:
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:color="@Color /Black"/>
<item android:state_enabled="false" android:color="@Color /Gray"/>
</selector>