例如,我只想在特定条件下选择一个目标。这怎么可能呢?提前谢谢。
<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>
发布于 2021-02-28 23:32:51
我只想在特定条件下选择一个目标
只有xml是不可能的。你可以在下面创建一个two animated vector resource files
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>
最后,关于后面的代码
val animatedVector
= if(condition that you want) {
ContextCompat.getDrawable(this, R.drawable.alles) as AnimatedVectorDrawable?
} else {
ContextCompat.getDrawable(this, R.drawable.alles2) as AnimatedVectorDrawable?
}
https://stackoverflow.com/questions/66406384
复制相似问题