I'm trying to display a dynamically-determined list of squares, side by side, on several different lines, in my Android app. When the number of boxes is "too great" for the given orientation, I want my app to start another line of boxes below (I'm aware of the underlying prerequisites: how big will each square be, how will this evolve with the screen size, density, orientation..., which I haven't determined myself yet). For now, however, I want to determine a high-level approach to meet this need. I also want the entire "list" of squares to be scrollable vertically (I'm aware I need to use a ScrollView for that).
Essentially, this is what I am trying to accomplish (please forgive the poor Paint skills).
Landscape (if there are 6 squares)
Portrait (if there are 12 squares)
To someone with a web development background it seems like a fairly easy task, however, I'm finding it much more difficult on Android than I expected.
Given the complexity of the whole task (if we're dealing with a medium sized device, then display 3 boxes in a LinearLayout if you're in portrait, then for every next 3, create a new LinearLayout beneath which contains them; if you're in landscape then it's 6; if it's a large device it's 4 and 7; ...) I see no other way, at the top of my head, than to handle all of this in Java, when the data is returned and the squares are initially created, as well as when the device orientation is altered.
As I'm just starting on native Android, I'd appreciate any help I can get on this.
Many thanks,
Chris.