简体   繁体   English

Android ImageView翻译动画

[英]Android ImageView Translate Animation

I am trying to animate a ImageView, scaling it down, fading it out and translating it to the top-left corner of the screen. 我正在尝试制作ImageView的动画,将其缩小,淡出并将其平移到屏幕的左上角。 This is what I got: 这就是我得到的:

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

<alpha
android:fromAlpha = "1.0"
android:toAlpha = "0"
android:duration = "900">
</alpha>
<scale
android:fromXScale = "1.0"
android:toXScale = "0" 
android:fromYScale = "1.0"
android:toYScale = "0" 
android:pivotX="0%"
android:pivotY="0%" 
android:duration = "900">
</scale>

<translate
    android:fromXDelta="0%" android:fromYDelta="0%" 
    android:toXDelta="-50.0%p" android:toYDelta="-50.0%p" 

    android:duration="900" 
    android:fillAfter="true" 
    />
</set>

Scaling and fading works fine, but the translation is not accurate. 缩放和淡入效果很好,但翻译不准确。 I want it to go to the top left corner of the screen. 我希望它转到屏幕的左上角。 How can I do that? 我怎样才能做到这一点?

thanks! 谢谢!

You have to move an object to the new coordinates once the animation is done. 动画完成后,您必须将对象移动到新坐标。 You see, the animation does not actually move the objects - it only animates the image. 您会看到,动画实际上并没有移动对象-它只是对图像进行动画处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM