图像正在回溯到旧位置,翻译,android,xml

时间:2013-05-04 16:50:49

标签: java android android-animation

我要做的是按照

将图像从当前位置设置为新图像

XML

<?xml version="1.0" encoding="utf-8"?>
<set
    xmlns:android="http://schemas.android.com/apk/res/android">

<translate
    xmlns:android       ="http://schemas.android.com/apk/res/android"
    android:fromXDelta  ="0"
    android:toXDelta    ="0"
    android:fromYDelta  ="0"
    android:toYDelta    ="-100"
    android:duration    ="2000"
    android:fillAfter   ="true"
     />

</set>

Java代码

        ImageView   logo01             =    (ImageView) findViewById(R.id.logo01);
        Animation   animation01        =    AnimationUtils.loadAnimation(this, R.anim.translate);
        animation01.reset();
        logo01.clearAnimation();
        logo01.startAnimation(animation01);

然而,在动画结束时,图像正在回溯到旧位置。我们怎样才能避免这种情况,以便最终图像处于新的位置。

1 个答案:

答案 0 :(得分:0)

我曾经遇到过类似的问题。我最终使用动态动画而不是xml:

TranslateAnimation anim = new TranslateAnimation(0,0,0,-100);
anim.setDuration(2000);
anim.setFillAfter(true);
logo01.setAnimation(anim);
相关问题