I have TransitionDrawable
defined in xml like this:
transition.xml
<?xml version="1.0" encoding="utf-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_disabled" />
<item android:drawable="@drawable/ic_enabled" />
</transition>
I use it to animate state changes of checkbox:
val stateDrawable = ContextCompat.getDrawable(this, R.drawable.transition) as TransitionDrawable
checkbox.buttonDrawable = stateDrawable
checkbox.setOnCheckedChangeListener { icon, checked ->
if (checked) {
stateDrawable.startTransition(300)
} else {
stateDrawable.reverseTransition(300)
}
}
If @drawable/ic_disabled
and @drawable/ic_enabled
are png
files, everything works fine. But if they are vector drawables, transition doesn't work. What am I missing? Does TransitionDrawable
not support vector drawables?