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
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):
- Position that ImageView on-screen.
- Set as its background an AnimationDrawable with following frames:
- empty Drawable: 1ms,
- normal Drawable: Tms.
- Change view’s animation to this:
- jump to off-screen position (translation with duration=1ms),
- do normal animation.
This is probably a good place to start looking for those who would use Fixpoint’s solution.