ingh.am
ingh.am

Reputation: 26742

Android View Design Issues

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

Upvotes: 1

Views: 440

Answers (4)

Nathan Schwermann
Nathan Schwermann

Reputation: 31493

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.

Upvotes: 0

dhaag23
dhaag23

Reputation: 6126

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).

Upvotes: 1

aprock
aprock

Reputation: 1592

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

Upvotes: 3

Zac Bowling
Zac Bowling

Reputation: 6578

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.

Upvotes: 2

Related Questions