[英]Animate only ONE target from AnimatorVectorDrawable
I want to select only one target on specific conditions for example.例如,在特定条件下,我只想 select 一个目标。 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>
I want to select only one target on specific conditions我想 select 在特定条件下只有一个目标
It is impossible only xml.不可能只有 xml。 You can make a two animated vector resource files
below您可以在下面制作two animated vector resource files
alles.xml 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 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?
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.