I have a drawable in this XML:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:endColor="@color/transparent"
android:gradientRadius="200dp"
android:startColor="?attr/primaryDarkTransparent"
android:type="radial" />
</shape>
The XML causes a crash when startColor uses ?attr/primaryDarkTransparent saying:
Caused by: java.lang.RuntimeException: org.xmlpull.v1.XmlPullParserException: <internal><gradient> tag requires 'gradientRadius' attribute with radial type
Caused by: org.xmlpull.v1.XmlPullParserException: <internal><gradient> tag requires 'gradientRadius' attribute with radial type
The dramatic story is that it works very well when I use attr in solid and stroke but I don't know what the hell is going on in gradient.
Any advices will be appreciated.
There are two problems in your shape.
Below Android L (API 21) you can't use attributes in custom drawables, so you should replace ?attr/primaryDarkTransparent with a color reference.
The gradientRadius should be a float. E.g. 200
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With