Basically, I have a main menu, and I would like the background image to scroll (parallax I believe is the term? Like the Angry Bird's title screen background).

However, I'm used to just having a variable iterate (x++) and setting that as the x value so the image scrolls.

So is there any way to confer variables and such between xml and my java files so I can use iteration? Or can I skirt this completely somehow?

  • \$\begingroup\$ It may actually be best I avoid xml sheets altogether and just do hard coding in Java, so I can implement "complex" effects like this. \$\endgroup\$
    – A13X
    Mar 10 '13 at 4:58

You can check this example of mine which scrolls the background. But I would not recommended that you have widgets or views on top of a SurfaceView animations. AngryBirds I believe draws its own graphics interface as all good games do.


  • \$\begingroup\$ Yes I found a tutorial on making an interface so I can write Java classes instead of working with the GUI activity xml layout >.< \$\endgroup\$
    – A13X
    Mar 28 '13 at 1:47
  • \$\begingroup\$ +5 :)) Trying to learn how to do these things, I've read a ton of tutorials and code. Your example (StackOverflow link) stands out among the best. The code is simple, clean, and directly addresses several key issues. So on a meta-level, it is in itself an example of a great example. Content-wise, it's spot on because it shows both non-threading and threading on the one hand and view extensions versus surface views on the other - while throwing in the use of canvas and bitmap. All key factors in learning basic game graphics on Android. Kudos! \$\endgroup\$ Oct 14 '13 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.