2

I have an Android game with a GridLayout that contains a custom ImageView in each of its cells. At certain points in this game I want to redraw several of these ImageViews at the same time (not sequentially).

If I call invalidate() on the parent ViewGroup, the GridLayout, will all the child views be redrawn at the same time? Is there a different or better way to redraw several child views at the same time?

Chamatake-san
  • 551
  • 3
  • 10
  • sounds a little too obvious but can't you use gridLayout.getChildAt(0).invalidate(); ? (replace "0" with the position of the imageView), I'm not very familiar with ViewGroups so i could be wrong – TomTsagk Apr 15 '15 at 05:38
  • @TomTsagk your suggestion will work fine for single ImageViews, but I have a series of maybe 4-8 ImageViews and I want them all to update at the same time (for example, I want an entire row of ImageViews to look like it's flashing and then disappearing, like in Tetris). I believe that when I loop through each view, similar to your suggestion, the user will see a slight delay between each redraw. – Chamatake-san Apr 15 '15 at 19:14
  • ooh I see what you mean, I'm afraid you picked the wrong way to create that. Using `GridLayout` is intended if you want its child views to behave independently, especially in the case of a game I'd advice you to create a single view (maybe a `SurfaceView`) and emulate a grid by yourself, that way you can draw any part of the screen you want at once – TomTsagk Apr 17 '15 at 09:20
  • @TomTsagk thanks for the good advice. You learn all sorts of stuff making your first game :) I'll look into SurfaceView or other similar options. – Chamatake-san Apr 17 '15 at 13:45

0 Answers0