views:

78

answers:

3

There is a variety of devices on the market, with different screen sizes, resolutions and pixel density.

What are some layout preferences or tips/tricks that are generally used to make sure the app looks the same across devices?

Thanks Chris

A: 

For a start, you could try positioning and scaling UI elements based of a percentage of the screen (for example, placing a button at 75% of the screen). In other circumstances, for example having a window attached to the right of the screen, just get the width of the screen minus the size of the window and place it there.

Dlaor
+2  A: 

I always use the "dip" as standart unity instead of pixels, use layout_weight to make proportions

and all my app's are fully compatible to 10 inches tablet devices and small smartphones with 3,2 inches screen!

Profete162
A: 

Make sure you grasp the different between wrap_content and fill_parent on the layouts. In in elements that are arranged vertically (like a list), you will almost always want wrap_content on the height and fill_parent on the width. Vice versa for elements arranged hortizontally.

As Profete162 said, always prefer the dip unit (it can be thought of as an abstracted pixel size). It helps insure that different resolution-densities don't break your hard-coded widths and heights. Ideally, there should never be a mention of dip in your theme code, but what is good in theory is not always pragmatic in practice.

These days, you should never use px for the size of something.

Kelly Sutton