1

enter image description here

I have 3 layout folders in my project:

1. layout

2. layout-large

3. layout-small

and as of now i don't have anything in layout-small but layout has layouts with small dimensions and layout-large has layouts with large dimensions.

The problem is:

when i test my app on a 240x320 it uses layouts from layout

when i test my app on a 480x800 even now it uses layouts from layout

Is it because thought i have layout-large, 480x800 doesn't fall into large screens, hence uses the default layout folder?

If that is the case, how can i make layouts for Normal Screens there is nothing like layout-normal or layout-medium.

Moreover, if i design my layout for HVGA (320x480) it should work perfectly for WVGA800 (480x800) since they both fall under same screen size, only density changes. And i am using dp everywhere. Am i right?

any help appreciated.

Mohammed Azharuddin Shaikh
  • 41,633
  • 14
  • 96
  • 115
Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226

4 Answers4

1

When it comes to xlarge, large and small then it is depending on size(inches) not on dpi of your device see below for specification

enter image description here

Additionally DPI is basically for Drawables while SIZE is for Layout.

Mohammed Azharuddin Shaikh
  • 41,633
  • 14
  • 96
  • 115
  • To be specific. 1 Major problem i face is: I ahve an image which must be **Match_parent** in width and **Half the parent** in height. So in layout i will use a 9-patch with **width = match_parent**, but how to set the height here?? probably ill set **height = 160dp** considering **HVGA (320x480)** this wont work with **WVGA800 (480x800)** – Archie.bpgc Nov 06 '12 at 07:01
  • No, You should use LinearLayout as a base and in child work with `Weight` property. – Mohammed Azharuddin Shaikh Nov 06 '12 at 07:03
  • eww. So every layout must use only LinearLayout with appropriate weights, if i got to support all the screen sizes?. so far i am using RelativeLayouts, if i have to change them to LinearLayouts it will be triple the code :( – Archie.bpgc Nov 06 '12 at 07:08
  • No, It depends. You need to decide when to use Relative/Linear but Linear works perfect when you give control area proportionately. Dont change simple create a sample project and learn LinearLayout you will definitely get to know when to use it. – Mohammed Azharuddin Shaikh Nov 06 '12 at 07:09
0

Just use the following details it may work but i am not sure..

res/layout/my_layout.xml             // layout for normal screen size ("default")
res/layout-small/my_layout.xml       // layout for small screen size
res/layout-large/my_layout.xml       // layout for large screen size
res/layout-xlarge/my_layout.xml      // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

res/drawable-mdpi/my_icon.png        // bitmap for medium density
res/drawable-hdpi/my_icon.png        // bitmap for high density
res/drawable-xhdpi/my_icon.png       // bitmap for extra high density

Just try....

Varun Vishnoi
  • 980
  • 1
  • 9
  • 32
0

You should check this developer page out it helped me alot. http://developer.android.com/guide/practices/screens_support.html

Even if they have different resolution or screen size that doesnt mean that they have different pixel density. For example a large screen may have less pixel density than a smaller screen.

Another example would be the Samsung Galaxy tab which is 10.1 inch but is still mdpi-large and Nexus One which is less than 5 inch but uses hdpi.

Best of luck

akemalFirdaus
  • 606
  • 1
  • 7
  • 15
0

I think I got what is going wrong with you........ lets try this. suppose you are going to make the application compatible for 480x800 resolution.So for that first of all create two folder for it i.e.

1.layout-sw480dp this is for landscape.

2.layout-sw480dp-port for portrait mode.

Now,put all layout of the resolution of 480X800 in it.you see it will run easily on the particular resolution.

Note:- point here to be noted that for any device resolution let A X B. the name of the layout folder is goes like this.

1.layout-swAdp.

2.layout-swAdp-port.

here "A" is the screen resolution height value of device.

i hope it work for you.

Aarun
  • 564
  • 1
  • 6
  • 13