Reputation: 1
I want to select only one target on specific conditions for example. How it is possible? Thanks in advance.
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_worldreloaded">
<target
android:name="alles"
android:animation="@animator/alles" />
<target
android:name="alles2"
android:animation="@animator/alles2" />
</animated-vector>
Upvotes: 0
Views: 103
Reputation: 192
I want to select only one target on specific conditions
It is impossible only xml. You can make a two animated vector resource files
below
alles.xml
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_worldreloaded">
<target
android:name="alles"
android:animation="@animator/alles" />
</animated-vector>
alles2.xml
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_worldreloaded">
<target
android:name="alles2"
android:animation="@animator/alles2" />
</animated-vector>
finally, on the code behind
val animatedVector
= if(condition that you want) {
ContextCompat.getDrawable(this, R.drawable.alles) as AnimatedVectorDrawable?
} else {
ContextCompat.getDrawable(this, R.drawable.alles2) as AnimatedVectorDrawable?
}
Upvotes: 0