'Apply android:tint on XML Selector to a VectorDrawable
My ImageButton have a background defined by a XML selector:
<ImageButton
android:id="@+id/button1"
android:layout_width="@dimen/size1"
android:layout_height="@dimen/size1"
android:layout_gravity="center"
android:background="@drawable/selector1"
android:clickable="true"
android:onClick="func1">
This selector changes the background image based on the current state of the ImageButton (pressed, focused, "normal") - applying or disabling a "tint" over the source image.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<bitmap android:src="@drawable/icon1"
android:tintMode="src_atop"
android:tint="#40FFFFFF"/>
</item>
<item android:drawable="@drawable/icon1" />
</selector>
These images are either WebP or PNG.
QUESTION: how can I obtain the same behaviour using VectorDrawable (SVG) files? <bitmap> does not allow using a VectorDrawable file as source.
I mean - use only one VectorDrawable for all different states and apply tint/mask to that VectorDrawable to increase brightness or highlight the icon.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
