I'm trying to define round drawable which needs primary color of material theme. Here's my xml code:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" >
<solid android:color="?attr/colorPrimary"></solid>
</shape>
But I'm getting InflateException
. I've read that we can not use attributes in drawable xml. So any workaround for this ?
Use app:drawableTint="@color/yourColor" in the xml instade android:drawableTint="@color/yourColor" .
colorPrimary and colorSecondary represent the colors of your brand. colorPrimaryVariant and colorSecondaryVariant are lighter or darker shades of your brand colors. colorSurface is used for “sheets” of material (like cards and bottom sheets) android:colorBackground is the window background color of your app.
xml" file located at res\values\colors.
If you are using API 21 or greater, you should use:
<solid android:color="?android:colorPrimary"></solid>
For older APIs you should just type:
<solid android:color="?colorPrimary"></solid>
Is your colorPrimary stored in yours colors.xml? If so, just reference it like @color/colorPrimary.
If not, just define it in colors.xml and reference it. These are the default teal color of meterial straight from the source code. I think material_deep_teal_500 is what you are looking for.
<!-- Primary & accent colors -->
<color name="material_deep_teal_200">#ff80cbc4</color>
<color name="material_deep_teal_500">#ff009688</color>
<color name="material_blue_grey_800">#ff37474f</color>
<color name="material_blue_grey_900">#ff263238</color>
<color name="material_blue_grey_950">#ff21272b</color>
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