According to en-SO, the problem is that before API 21 you cannot use color-reference attributes in xml-drawable , only the color references from @color . In this case, convert the file as follows:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:angle="90" android:endColor="@color/my_awesome_color_that_i_use_as_color_primary_in_my_awesome_theme" android:startColor="@android:color/transparent"/> </shape>
If, like me, you need to use the same xml-drawable but with different colors for different themes, then nothing remains except:
Create an attribute link to xml-drawable
<?xml version="1.0" encoding="utf-8"?> <resources> <!-- по ссылке утверждают, что надо обязательно только lowerCase пользовать в названии --> <attr name="my_drawable" format="reference" /> </resources>
Assign a link to a separate xml-drawable in this attribute for each topic.
<style name="MyTheme" parent="@android:style/Theme.NoTitleBar"> <item name="my_drawable">@drawable/my_drawable_for_this_theme</item> </style>
use this attribute where appropriate. for example a textView background
<TextView android:background="?my_drawable" />
Of course, don't forget to create one xml-drawable with a specific color for each theme.