【问题标题】:Animation Scaling Glitch动画缩放故障
【发布时间】:2014-09-09 04:39:00
【问题描述】:

当我将此动画添加到相对布局中的图像视图时,图像会跳转到更大的比例,然后才能平滑地增长和缩小(然后跳转回其原始大小)。

当我在下面显示的文件中注释掉第二个“缩放”动画时,不会发生这种意外的跳跃。为什么?我想不通。

主活动:

ImageView image = (ImageView)findViewById(R.id.imageView1);
        Animation animation = AnimationUtils.loadAnimation(getApplicationContext(),    R.anim.myanimation);         
        image.startAnimation(animation);

myanimation.xml:

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

<scale
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="2000"
    android:fromXScale="1.0"
    android:fromYScale="1.0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toXScale="3.0"
    android:toYScale="3.0" >
</scale>
<scale
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="2000"
    android:fromXScale="3.0"
    android:fromYScale="3.0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:startOffset="2000"
    android:toXScale="1.0"
    android:toYScale="1.0" >
</scale>

</set>

【问题讨论】:

    标签: android android-animation scale


    【解决方案1】:

    尝试以下操作:

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android" >
    
        <scale
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:duration="2000"
            android:fromXScale="1.0"
            android:fromYScale="1.0"
            android:pivotX="50%"
            android:pivotY="50%"
            android:toXScale="3.0"
            android:toYScale="3.0" >
        </scale>
        <scale
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:duration="2000"
            android:fromXScale="1.0"
            android:fromYScale="1.0"
            android:pivotX="50%"
            android:pivotY="50%"
            android:startOffset="2000"
            android:toXScale="0.33"
            android:toYScale="0.33" >
        </scale>
    
    </set>
    

    【讨论】:

    • 花了我一秒钟来了解答案的要点,但它确实解决了我的问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-09-27
    • 1970-01-01
    • 2014-11-24
    • 2013-07-28
    • 1970-01-01
    • 1970-01-01
    • 2022-10-23
    相关资源
    最近更新 更多