2

I have a nav drawer which contains a TableLayout with a few TableRows, each simply containing a TextView. Upon the drawer opening, Id like to do a very small sliding in animation of the TableRows/TextViews, where they each slide in a tad later than the previous, very similar to the drawer found in the Sprig app:

https://play.google.com/store/apps/details?id=com.eatsprig&hl=en

I know that usually for a simple animation I would create a xml file in /res/anim/ and then load the animation with AnimationUtils.loadAnimation(context, R.anim.myanim) and then start the animation with the .startAnimation() method, but im not sure how to go about doing an animation as described above. Does anyone know how to do this?

Orbit
  • 2,985
  • 9
  • 49
  • 106
  • 1
    I'd add a `AnimationListener` for each `Animation` and start the next `Animation` `onAnimationEnd`. You can test it with the default `android.R.anim.slide_in_right` `Animation` – yennsarah Jan 14 '16 at 08:06
  • Well with 5+ items thats quite a few nested callbacks, surely theres another way? Also, is there a way to set the animation via xml? I see android:layoutAnimation but im assuming that would only be called on initial layout, not everytime the drawer opens. – Orbit Jan 14 '16 at 08:12
  • 1
    Yep, but you could use the same `Animation` again. (Maintaining your `Views` in an `Array`, counting which... etc.) [This](http://stackoverflow.com/a/27563468/4908802) is not what you want, but maybe it can inspire you. You could start each `Animation` on a specific offset. – yennsarah Jan 14 '16 at 08:22
  • Thanks, will take a look. – Orbit Jan 14 '16 at 08:26

0 Answers0