用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 (将#修改为@)