Android的动画与套

编程入门 行业动态 更新时间:2024-10-28 01:17:19
本文介绍了Android的动画与套的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个这样的动画:

<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="schemas.android/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="schemas.android/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?

推荐答案

对于组中的第二个动画,你要使其后的第一个启动,以抵消动画。您可以通过使用偏移属性做到这一点:developer.android/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: developer.android/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的动画与套

本文发布于:2023-11-30 10:34:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1649670.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:动画   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!