Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Color selector for vector image doesn't work

I have a vector image (svg converted to xml):

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:better="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="NewApi"
    android:viewportWidth="24"
    better:viewportWidth="24"
    android:viewportHeight="24"
    better:viewportHeight="24"
    android:width="24dp"
    android:height="24dp">
    <path
        android:pathData="M10.09 15.59l1.41 1.41 5 -5 -5 -5 -1.41 1.41 2.58 2.59 -9.67 0 0 2 9.67 0 -2.58 2.59zM19 3L5 3C3.89 3 3 3.9 3 5l0 4 2 0 0 -4 14 0 0 14 -14 0 0 -4 -2 0 0 4c0 1.1 0.89 2 2 2l14 0c1.1 0 2 -0.9 2 -2L21 5C21 3.9 20.1 3 19 3Z"
        better:pathData="M10.09 15.59l1.41 1.41 5 -5 -5 -5 -1.41 1.41 2.58 2.59 -9.67 0 0 2 9.67 0 -2.58 2.59zM19 3L5 3C3.89 3 3 3.9 3 5l0 4 2 0 0 -4 14 0 0 14 -14 0 0 -4 -2 0 0 4c0 1.1 0.89 2 2 2l14 0c1.1 0 2 -0.9 2 -2L21 5C21 3.9 20.1 3 19 3Z"
        android:fillColor="@color/menu_color_selector"
        better:fillColor="@color/menu_color_selector" />
</vector>

But the color selector doesn't work. Is it possible to achieve what I am trying to do?

like image 939
pvllnspk Avatar asked Nov 04 '15 08:11

pvllnspk


1 Answers

Try to use StateListDrawable with different VectorDrawable for each required state.

like image 126
Paha Avatar answered Oct 19 '22 11:10

Paha