cómo desarrollar dos capas de imágenes y ambas capas deben tener alguna actividad de movimiento en Android

i want to have a background image and it should have some motion. then in the foreground another image which should also have some other motion.i.e two layer of images each having separate motion event

preguntado el 02 de febrero de 12 a las 10:02

3 Respuestas

You can stack two views on top of each other with a FrameLayout or RelativeLayout and apply animations to each one of them with startAnimation().

Respondido 02 Feb 12, 14:02

yes i did all that but i dont know how to apply animation with start animation. can u help me - karthi B

maybe you can post an excerpt of your code since I cannot tell what exactly you need help with. - Thorstenvv

Use Bitmap or Drawable to draw your image. So you will have something like this -

Assuming you have image1 and image2 in res/drawable folders and you know how to load them in your program.

Drawable backgroundImage = res.getDrawable(R.drawable.image1);
Drawable foregroundImage = res.getDrawable(R.drawable.image2);

backgroundImage.setBounds(x1, y1, x1 + width, y1 + height);
foregroundImage.setBounds(x2, y2, x2 + width, y2 + height);

// You need to declare Canvas in your code to use Drawable

Now through your code, control (x1,y1) and (x2,y2) to have separate motion for the two images. Hope that helps

Respondido 02 Feb 12, 15:02

sorry am new to android i dont know wat all to add in the above code. can you help me out - karthi B

In that case I would suggest go through the following guide..developer.android.com/guide/topics/graphics/2d-graphics.html - Arun Singh

PLace the two image views in a frame layout initially and then apply the animation scheme to them.
Start the animation for both the views and they will move.
For applying animation you can create an animation xml in the "anim" in the "res" folder.
Info regarding this can be collected from

Respondido 02 Feb 12, 15:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.