Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
390 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 Answer

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...