My question is related to this one: link. I've recently changed most of my resources for Android from different png files for different resolutions to vector drawables. I'm using a "swipe-to-delete" library that can change the background of its views during the swipe to show a Gmail-style red background with a trashcan icon, something similar to this (which has a green background with a check icon) :
I used to do that using the following code, and I still do for < API 21
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="@color/accent"/>
</item>
<item android:right="@dimen/activity_horizontal_margin">
<bitmap
android:gravity="right|center_vertical"
android:src="@drawable/ic_delete_24dp"/>
</item>
</layer-list>
However, different syntax is required for API 21+
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="@color/accent" />
</item>
<item android:right="@dimen/activity_horizontal_margin"
android:drawable="@drawable/ic_delete_24dp"
android:gravity="right|center_vertical"/>
</layer-list>
Now, instead of an icon on the left/right hand side, the icon on API 21 & API 22 (Lollipop) is stretched to fill the screen. Is there any way to specify the width of the icon?
android:drawable
gives crash in API 19 andapp:srcCompat
doesnt seem to work inlayer-list
. How are you handling it? – Photoneutron