如何解决用Java更新对象动画带有向量中XML文件的最佳方法是什么?
我用object-Animatior创建了一个动画,其中包含四个 XML 文件( pivotX , pivotY , scaleX , scaleY )。 覆盖其值的最佳,最有效的方法是什么?
重要的是,我将动画用于矢量图形。 我读到有关DOM分析器以解析XML并覆盖它们的信息,但是许多人说这不是有效的方法。在我的最终代码中,我将有200多个国家/地区,如果用户单击了某个国家/地区,则应该更新数据透视和缩放XML,因此可以从所单击的国家/地区(从(Valueto)到用户所在的国家/地区(Valueto))开始缩放将单击下一步。如何使用Java做到这一点? 也许我完成其他方法?也许我不需要XML的解析器?我只想更新它们。
动画本身是有效的,但是我需要用Java覆盖重要的XML(包装在不同的条件下,例如按钮等)。
我的工作动画 main.java :
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
....
click = (Button) findViewById(R.id.button);
AnimatedVectorDrawable animation2;
click.setonClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Drawable test = neu.getDrawable();
if (test instanceof AnimatedVectorDrawable) {
Log.d("testanim",test.toString());
animation2 = (AnimatedVectorDrawable) test;
animation2.start();
}
}
});
animatorvectordrawable.xml:
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_worldreloaded"
>
<target
android:name="rotationGroup"
android:animation="@animator/scalex" />
<target
android:name="rotationGroup"
android:animation="@animator/scaley" />
<target
android:name="rotationGroup"
android:animation="@animator/pivotx" />
<target
android:name="rotationGroup"
android:animation="@animator/pivoty" />
</animated-vector>
pivotx.xml:
<objectAnimator
android:duration="2300"
android:propertyName="pivotX"
android:valueFrom="0"
android:valueto="2600"
xmlns:android="http://schemas.android.com/apk/res/android" />
pivoty.xml:
almost the same as pivotx
scalex.xml:
<objectAnimator
android:duration="4000"
android:propertyName="scaleX"
android:valueFrom="1"
android:valueto="14"
xmlns:android="http://schemas.android.com/apk/res/android" />
scaley.xml:
almost the same as scalex
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。