Chris
Chris

Reputation: 361

Android - How to make UI look same across devices?

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

Upvotes: 2

Views: 1971

Answers (3)

Kelly Sutton
Kelly Sutton

Reputation: 591

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.

Upvotes: 1

Waza_Be
Waza_Be

Reputation: 39538

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!

Upvotes: 3

Dlaor
Dlaor

Reputation: 3020

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.

Upvotes: 1

Related Questions