views:

71

answers:

4

I've been playing about with the layout of a view with Android (lets say within the MainActivity) and I'm looking to create this sort of layout using 3 ImageView's (where each block represents an image):

alt text

This is rather easy to pull of using LinearLayout's but only if you specify the exact size and position of each ImageView. This then obviously causes problems when looking at different screen sizes.

Using AbsoluteLayout looked like it was going to work at first, but I've read that it's deprecated and it still causes problems with different screen sizes.

Then there is RelativeLayout, which I've tried using with DroidDraw, but it doesn't seem to get me very far when I implement it :(

So, does anyone have an ideas of how to achieve this?

EDIT: I've got close to doing this using dp instead of px but this still gets screwed up when using larger resolution devices! :(

Thanks

+2  A: 

One solution is that you could use a TableLayout with 2 columns, and then in the second column embed a second TableLayout.

DroidDraw doesn't always show exactly how it will work when it runs 100% of the time I've noticed.

Zac Bowling
Yes, I've noticed that too. I also noticed there are some java commands you can call which you can not in DroidDraw such as setting the scale type. I will try the TableLayout method. Thanks
ing0
Yuk, relative layouts and weights are always better to use than tables imo
schwiz
Why are they better? I'm about to try Romain Guy's layout tricks as aprock suggested.
ing0
+3  A: 

Romain Guy does something very similar using RelativeLayout. Android Layout Tricks #1

aprock
+1  A: 

You can do this with a horizontal LinearLayout: add the green first, then add a vertical liner layout for the blue and orange and give each an appropriate weight (like 50 and 50).

dhaag23
What does layout_weight do?
ing0
A: 

You can still use LinearLayout but make the width/height in dip units. Thatvway it should look the same on any supported screen size. Alternativly, you could use the weight attribute instead which is probably a better idea for this case.

schwiz