Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
388 views
in Technique[技术] by (71.8m points)

android - How to run several translate animations sequentially?

I want to run the three translate animations shown below sequentially. i.e. after one translate animation ends, the second translate animation starts. However, they run concurrently.

Additionally, this animation will be used for overridePendingTransition() as a parameter. So, I have to solve this problem, only by using XML code.

Is there anyone who knows what I should do?

<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">

<translate
    android:fromXDelta="100%p"
    android:toXDelta="-20%p"
    android:duration="1000" />

<translate
    android:fromXDelta="-20%p"
    android:toXDelta="20%p"
    android:duration="1000" />

<translate
    android:fromXDelta="20%p"
    android:toXDelta="0"
    android:duration="1000" />
</set>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Use android:startOffset to delay animations.

With your example, this should do what you want:

<set
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fillAfter="true">

    <translate
        android:fromXDelta="100%p"
        android:toXDelta="-20%p"
        android:duration="1000" />

    <translate
        android:startOffset="1000"
        android:fromXDelta="-20%p"
        android:toXDelta="20%p"
        android:duration="1000" />

    <translate
        android:startOffset="2000"
        android:fromXDelta="20%p"
        android:toXDelta="0"
        android:duration="1000" />
</set>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...