Android的动画与套 [英] Android animation with sets

查看:179
本文介绍了Android的动画与套的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的动画:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false"
    android:fillAfter="true" >
<translate
    android:interpolator="@android:anim/decelerate_interpolator"
    android:duration="600"
    android:fillAfter="true"
    android:fromXDelta="10"
    android:fromYDelta="0"
    android:toXDelta="0%"
    android:toYDelta="-500" />

    </set>

和它的作品太棒了,但是这不是我所想要做的,我要的观点上去,然后回去了。要做到这一点,然后我改变动画以下内容:

And it works fantastic, however this is not all I want to do, I want the view to go up and then to go back down. To accomplish this I then change the animation to the following:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false"
    android:fillAfter="true" >
<translate
    android:interpolator="@android:anim/decelerate_interpolator"
    android:duration="600"
    android:fillAfter="true"
    android:fromXDelta="10"
    android:fromYDelta="0"
    android:toXDelta="0%"
    android:toYDelta="-500" />
    <translate
        android:interpolator="@android:anim/decelerate_interpolator"
        android:duration="600"
        android:fillAfter="true"
        android:fromXDelta="10"
        android:fromYDelta="0"
        android:toXDelta="0%"
        android:toYDelta="500" />

    </set>

不过那是行不通的。我想一个动画对方后exevute,但我猜测,他们都在同一时间执行。在这种情况下,我只需要能够做的第一动画的对面,不过,我想知道如何做一个规模之后,翻译等。我需要两个独立的动画?什么是一次运行之后对方,而不是所有的动画正确的方法是什么?

However then it doesn't work. I would like one animation to exevute after the other, however I am guessing that they are both executing at the same time. In this case I simply need to be able to do the opposite of the first animation, however I would like to know how to do a scale after a translate and so on. Do I need two separate animations? What is the correct way to run animations after each other instead of all at once?

推荐答案

对于组中的第二个动画,你要使其后的第一个启动,以抵消动画。您可以通过使用偏移属性做到这一点:<一href=\"http://developer.android.com/reference/android/view/animation/Animation.html#attr_android:startOffset\" rel=\"nofollow\">http://developer.android.com/reference/android/view/animation/Animation.html#attr_android:startOffset

For the second animation in the set, you want to offset the animation so that it starts after the first one. You can do this by using the offset attribute: http://developer.android.com/reference/android/view/animation/Animation.html#attr_android:startOffset

<translate
    android:interpolator="@android:anim/decelerate_interpolator"
    android:duration="600"

    android:startOffset="600"

    android:fillAfter="true"
    android:fromXDelta="10"
    android:fromYDelta="0"
    android:toXDelta="0%"
    android:toYDelta="500" />

这篇关于Android的动画与套的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆