2

I am really confused about supporting multiple screen sizes/resolutions/densities etc.

Here's the dilemma:

I am breaking my application's GUI into four categories - small, normal, large, Xlarge.

So the phone I am testing on is a normal screen size, 3.2" HTC MyTouch3G. Now, I also found out that a 3.7" screen is also called normal - among some other sizes.

How can I possibly go about supporting so many different screen sizes?

My application's main layout is wrapped in a ScrollView. To test things out, I made the normal sized layout to look right on a 3.7" screen (recall my phone is 3.2"). When I installed the app on my phone, the whole view scrolls because all the graphics are too big. But it won't scroll horizontally, everything was resized horizontally but not vertically.

So is there any way for me to design the app to fit all screen sizes within a category like normal or large?

Thanks.

capcom
  • 3,257
  • 12
  • 40
  • 50

1 Answers1

2

In general you have to design your UI to fit all screen sizes under the same category "I usually make it fit the smallest size and try to use layout_weight property when it fits so the views scale with the screen size", you can use android sdk xml editor to see how your UI looks like under each screen size.

If you find this approach inconvenient for any reason you have , you always can do things manually (measuring screen size using

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;

and do your calculations then apply them to your view's width , height properties.

Mr.Me
  • 9,192
  • 5
  • 39
  • 51
  • Excellent answer! Do you know how I could retrieve the screen size in dp instead for any screen size? – capcom Aug 10 '12 at 23:21
  • You can convert pixels to dips using [this answer](http://stackoverflow.com/questions/6656540/android-convert-px-to-dp-video-aspect-ratio). – Cat Aug 10 '12 at 23:33
  • 1
    Thanks. Also, you might want to edit your code to show `Display display = getWindowManager().getDefaultDisplay();`. You're missing the capital *D* on `Display`. – capcom Aug 10 '12 at 23:40