0

I have a home screen on my app and several fragments with different content that I add programmatically at the start of this screen. I'm trying to animate the appearance of each fragment and I want for them to show one after another but can't figure it out, they all appear at the same time.

My best guess was to use different animation files with different startOffset

animation_1.xml

<?xml version="1.0" encoding="utf-8"?>
<scale  xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fromXScale="0.0"
    android:toXScale="1.0"
    android:fromYScale="0.0"
    android:toYScale="1.0"
    android:duration="500"
    android:pivotX = "50%"
    android:pivotY = "50%" />

animation_2.xml

<?xml version="1.0" encoding="utf-8"?>
<scale  xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fromXScale="0.0"
    android:toXScale="1.0"
    android:fromYScale="0.0"
    android:toYScale="1.0"
    android:duration="500"
    android:startOffset="500"
    android:pivotX = "50%"
    android:pivotY = "50%" />

but I'm gonna add like 10 different fragments and I don't think this is the most effective way to do it. ¿Any ideas?

Carlos J
  • 2,965
  • 4
  • 17
  • 28
  • check this [link][1] in another post [1]: http://stackoverflow.com/questions/4932462/animate-the-transition-between-fragments – Chefes May 14 '14 at 21:26
  • Thanks, but I already know how to make the animations. What I'm trying to accomplish is to use the same animation and show different fragments one after another not at the same time. – Carlos J May 14 '14 at 21:39

1 Answers1

0

Add this to your second fragment animation

android:startOffset = "x"

where x will be the animation time for you first fragment

Matthew Mullin
  • 7,116
  • 4
  • 21
  • 35