As @Jahnold mentioned in a comment on the question, support for loading a vector ported from an xml state xml list was removed in 23.3.
However, I found several approaches that may help.
1. Using shade
The approach is suitable if the drawings from the selected list of states differ only in colors.
First, create only one vector that you can draw with a tint and white fillColor :
<?xml version="1.0" encoding="utf-8"?> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" android:tintMode="multiply" android:tint="@color/button_tint"> <path android:fillColor="#ffffff" android:pathData="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/> <path android:pathData="M0 0h24v24H0z"/> </vector>
Secondly, create a list of button_tint.xml color button_tint.xml located in res/color
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:color="#555555" android:state_enabled="false"/> <item android:color="#6699dd"/> </selector>
Remember to add the lines below to build.gradle or the approach will not work on older versions of Android.
defaultConfig { vectorDrawables.useSupportLibrary = true }
2. Creating Hard Code StateListDrawable
The approach is suitable if you use vector elements for the list, which differ not only in color but also in shape, so you need to create several different xml files. Then you can create a StateListDrawable programmatically, as shown in.
Sergei Vasilenko Apr 27 '16 at 9:49 on 2016-04-27 09:49
source share