I was looking at the documentation for GradientColor https://developer.android.com/reference/android/R.styleable.html#GradientColor . How can I define a gradient color in XML and apply it to an XML vector drawable?
I have tried in color.xml, styles.xml and within an XML vector drawable.
I get the error " Failed to convert @id/gradclor into a ColorStateList" with:
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="120dp"
android:height="120dp"
android:viewportWidth="120.0"
android:viewportHeight="120.0">
<path
android:name="play_triangle"
android:pathData="M 30 30 L 30 90 L 80 60 z"
android:strokeColor="@id/gradclor"
android:strokeWidth="5"/>
<color
android:name="@+id/gradclor"
android:startColor="#FFFFFF"
android:endColor="#00FFFF"
android:angle="145"/>
</vector>
or "Failed to convert #FFFFFFFF #00FFFFFF 145 into a ColorStateList" when using:
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="120dp"
android:height="120dp"
android:viewportWidth="120.0"
android:viewportHeight="120.0">
<path
android:name="play_triangle"
android:pathData="M 30 30 L 30 90 L 80 60 z"
android:strokeColor="@color/GradientStrokeBorder"
android:strokeWidth="5"/>
</vector>
with the following in color.xml:
<color name="GradientStrokeBorder">
<item name="android:startColor">#FFFFFF</item>
<item name="android:endColor">#00FFFF</item>
<item name="android:angle">145</item>
</color>
@color/blue_gradient
) in res/drawable-v24 and a version referring to a regular color in res/drawable. – Propel