views:

25

answers:

1

I have a RelativeLayout filling the screen and a couple of ImageView positioned on it using LayoutParams margins. These ImageView are animated in different ways, and in one case I want an image to "fly in" to the screen from the right.

Unfortunately, if I set leftMargin for that ImageView greater than the width of the screen, it does not appear (or appears cropped if it partially visible at the start of animation).

I tried setting width and height of RelativeLayout to be bigger than screen size - it works, but only partially: if the image is positioned completely off-screen, it does not work, and if the image is partially visible, it is not cropped, but that works only for right and bottom sides.

So, my question is this: how to position several ImageViews on and off the screen so that I can animate them using Animation?

A: 

In the end, I used a trick: I combined AnimationDrawable and view animation. I did the following (assuming that the animation has to run T milliseconds):

  1. Position that ImageView on-screen.
  2. Set as its background an AnimationDrawable with following frames:
    • empty Drawable: 1ms,
    • normal Drawable: Tms.
  3. Change view's animation to this:
    • jump to off-screen position (translation with duration=1ms),
    • do normal animation.
Shooshpanchick