Reputation: 411
I am trying to program to multiple screens. I currently have two devices:
Samsung Galaxy S2 with a screen of 4 inches: 480x800 density: 1.5 Height (dp): 533.3333 Width (dp): 320.0 screenLayout: 34 = 0010 0010
Samsung Young with a screen of 3.2 inches: 320x480 density: 1.0 Height (dp): 480.0 Width (dp): 320.0 screenLayout: 18 = 0001 0010
So, the devices differ in density and screenLayout (SCREENLAYOUT_LONG_YES vs. SCREENLAYOUT_LONG_NO).
I prepared image buttons in two sizes and put them in drawable-mdpi (for the higher resolution) and in drawable-ldpi (for the lower resolution). The image buttons have the same name.
I also wrote two different layouts, yet, with the same file name and put them in the layout folder (for the higher resolution) and in the layout-small (for the lower resolution).
I left the Java code with no changes, i.e., it doesn't check the resolution for selecting high or low resolution.
The problem is, that the two devices go to the same folder, both in layout and both in drawable.
What am I doing wrong? What is the right way to handle multiple screen sizes in android?
Thanks! AJ
Upvotes: 1
Views: 1023
Reputation: 4930
I think you just use the wrong folder for your devices.
As you can see in the section of Range of screen supported the ranges have no strict bounds.
It is important to know which DPI your device have:
In the section "Using configuration qualifiers" of the posted linke above you have a table where the densities are described:
So try to put your layout and image from your mdpi
to your hdpi
folders and from ldpi
to mdpi
.
You also could try to use the new size qualifiers, where you can define your layout depending on the e.g. smallest width of your device.
Upvotes: 0
Reputation: 6533
Add layout in Every Folder
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
in manifest file
<supports-screens android:resizeable=["true"| "false"]
android:smallScreens=["true" | "false"]
android:normalScreens=["true" | "false"]
android:largeScreens=["true" | "false"]
android:xlargeScreens=["true" | "false"]
android:anyDensity=["true" | "false"]
android:requiresSmallestWidthDp="integer"
android:compatibleWidthLimitDp="integer"
and for more detail link
Upvotes: 2