Repox
Repox

Reputation: 15474

Screen sizes and layouts

I'm currently stuck at what might be a problem with understanding the docs.

I've been reading the docs about supporting multiple screens and I'm having some issues specifically with layoyt differences between the HTC Desire and the HTC Legend.

From my understanding, by looking at the screen matrix in the developer docs, the Legend is a 'normal' screen and the Desire is a large screen.

Adding layout directories layout/, layout-small/ and layout-large solved my problems with small screen devices. But now, when trying to make the app look good in both the Desire and the Legend, it seems like they both use the normal screen layout.

Any hints, solutions or explanations?

Upvotes: 3

Views: 1460

Answers (3)

dLobatog
dLobatog

Reputation: 1741

Try to use wrap_content, fill_parent, or the dp unit in your normal layout. Anyway creating several layouts as you are doing is a tedious but maybe better option. Set this in your manifest

  <supports-screens 
    android:largeScreens="true" 
    android:smallScreens="true" 
    android:normalScreens="true" 
 />

and get the size of the screen in use with

DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
height = displaymetrics.heightPixels;
width = displaymetrics.widthPixels;
Log.e("FirstImage", "Width = "+width+"Height = "+height);

Once you have the size of the screen I think you know how to assign it a certain predefined (by you) layout.

I hope this helps, if you still have any prob, comment below and we'll see how to solve it!

Upvotes: 0

futtetennista
futtetennista

Reputation: 1876

HTC Desire - whose screen is 480x800 WVGA800 - is considered to be normal screen-hdpi, while HTC Legend - whose screen is 320 X 480 HVGA - is considered to be normal screen-mdpi (look at Table 1 here). So the normal screen layout and mdpi graphics are used for both devices, but since the Desire has a hdpi screen, Android scales up the graphic (generally the result is that they look blurry). In order for the layout to look good on the Desire you should provide hdpi graphics and put them in a folder named drawable-hdpi.

Upvotes: 2

sat
sat

Reputation: 41096

In layouts I use layout weights to specify the dimensions. That will help to large extent when running app in various screen devices.

Check about layout_weights here,
http://mobiforge.com/designing/story/understanding-user-interface-android-part-1-layouts

Upvotes: 0

Related Questions