I am using DataBinding to tint vector drawable of ImageView on basic of an boolean flag. This code works well for >=21 version. But fails in <21 version.
<androidx.appcompat.widget.AppCompatImageView
android:tint="@{model.nextEnabled ? @color/primary : @color/silver}"
app:srcCompat="@drawable/ic_right_blue_24dp"
/>
Here ic_right_blue_24dp is a vector drawable.
After checking binding class, I could see that code for <21 version is not getting generated.
if(getBuildSdkInt() >= 21) { this.mboundView1.setImageTintList(androidx.databinding.adapters.Converters.convertColorToColorStateList(modelBackEnabledMboundView1AndroidColorPrimaryMboundView1AndroidColorSilver)); }
I have tried all things I could think, and could find.
- AppCompatImageView
- ImageView
app:srcCompatandroid:srcapp:tintvectorDrawables.useSupportLibrary = trueAppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
Here I must tell you that all things work using regular tint without binding.