2

I want to have this layout in my Android app.

The layout I want to implement

Requirements:

  • All rectangles should distribute evenly over the entire screen
  • The two rectangles on the bottom right should have the same height (so also distributed evenly)

I tried GridLayout but that won't let me stretch the children across the screen. I tried RelativeLayout without success. I tried nesting LinearLayouts with weights, it works, but I read that nesting weights is bad for performance. And finally, I tried TableLayout with weights, but it does not have something like "row span" like an HTML table so I cannot do the two rectangles in the bottom right corner like I want them to be (without nesting weights again).

Somebody, please help! How hard can it be? I don't know what to do here. I could implement my own ViewGroup or something to manually implement the layout. But it feels like this is something very simple, so I should be able to use standard layouts.

Tom van Zummeren
  • 9,130
  • 12
  • 52
  • 63
  • "I don't know what to do here" -- considering that you already did it, that's a strange statement to make. It would seem to make more sense for you to see if you have an actual performance issue with the `LinearLayout` solution, before wasting time worrying about rolling your own `ViewGroup`. – CommonsWare Dec 08 '13 at 20:07

1 Answers1

1

You are able to use GridLayouts to do such a thing, for some help fitting the screen I suggest you look at the following: How to make a GridLayout fit screen size.

Depending on what you are doing, nested weights with a series of Linear Layouts will not harm your performance too much, however it is is something extremely large like an intricate game or something of that nature I suggest using the GridLayout.

Community
  • 1
  • 1
Bedimindtricks
  • 113
  • 1
  • 7
  • Thanks! I am using IntelliJ IDEA and it started complaining about the nested weights. So I thought it was a major performance issue. But if you're telling me it isn't, I will ignore the warnings. – Tom van Zummeren Dec 08 '13 at 20:16