I have added themes to my application. For this I have used multiple accent colors to add on image button. I have a xml file named fab selector xml , which gives shape and color to image button. But its giving exceptions on this file.
1st exception is inflateException for class image button. 2nd is resource not found Exception for fab selector. Fab selector resides in drawable folder.
Its also showing ,, Caused by: java.lang.UnsupportedOperationException: Can't convert to color: type=0x2
if i use <solid android:color="?attr/colorAccent" />
?attr/colorAccent and it works fine if I use
<solid android:color="@color/colorAccent">
as it gives hex color value.
The strange thing same way I have applied this to toolbar and it works below lollipop as well. Only it's giving exception on fab selector file.
I don't understand how can I overcome this?
Fab selector
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <shape android:shape="oval"> <solid android:color="?attr/colorAccent" /> </shape> </item> <item android:state_focused="true"> <shape android:shape="oval"> <solid android:color="?attr/colorAccent" /> </shape> </item> <item> <shape android:shape="oval"> <solid android:color="?attr/colorAccent" /> </shape> </item> </selector>
Log:
Edit: I have mentioned colorAccent in style.xml
<!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="android:textColorSecondary">@color/white</item> <item name="windowActionBarOverlay">false</item> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> <item name="android:windowBackground">@color/background_material_light</item> </style>
What to do? Thank you..