support for multiple resolution android - android

My app has 2 different resolution support, 480x800 and 320x240, i have created folder for them for instance layout-normal-hdpi and layout-normal-mdpi. But somehow emulotor is not picking up the ui for hdpi. I have created different layout aswell.

the way i am dealing with multiple screen is this way and its working fine.....if any one has improved wayso do guide me
Screen size 480x800
layout-normal-hdpi-480x800
drawable-normal-hdpi-480x800
Screen size Galaxy Nexus---
though its size is 1280x720 but in actual due to system bar its dimension(screen size) differs
layout-normal-xhdpi
drawable-normal-xhdpi
Screen size Note 5.3---
layout-normal-xhdpi-1280x800
drawable-normal-xhdpi-1280x800
Screen size S3---
layout-normal-xhdpi-1280x720
drawable-normal-xhdpi-1280x720
Screen size 7inch tab 2 supporting OS version 3 and above---
dont write dimension 1026x600 bsz in actual due to system bar its dimension(screen size) differs
layout-large-mdpi
drawable-large-mdpi
Screen size 7inch tab p1000 etc supoorting os verion less than 3---
layout-large-hdpi-1024x600
drawable-large-hdpi-1024x600
Screen size 1280x800 tab 10.1,10.2,note 10.1 etc---
you can add dimension if you want other wise it is fine
layout-xlarge-mdpi
drawable-xlarge-mdpi

From the documentation:
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
layout-normal-mdpi does not exist. Use layout-mdpi instead.
For reference: http://developer.android.com/guide/practices/screens_support.html
The Api level must also support this: Android - layout-large folder is been ignored

Handling different resolutions can get tricky on Android.
The one true resource for this is the official site:
http://developer.android.com/guide/practices/screens_support.html
It sounds to me like you might be confusing the size with the pixel intensity here.
Try to create the folders:
res/layout-sw480dp/main_activity.xml //for the large screen
and
res/layout-sw320dp/main_activity.xml //for the small one
Do you also have different drawable resource folders? Did you manage to get them to work?

Android Support Multiple Screeen
for tablet
Resolution 1280x800/1280x720
values-sw720dp
drawable-sw720dp
layout-sw720dp
Resolution 1024x600
values-sw600dp
drawable-sw600dp
layout-sw600dp
Resolution 480x800(twinner resolution, mdpi in tablet & hdpi in mobile)
values-large-mdpi
drawable-large-mdpi
layout-large-mdpi(incase you want to make separate layout)
for moblie
Resolution 1080x1920
values-sw360dp-xxhdpi/values-sw360dp-notlong-xxhdpi (when 768x1280 is used)
drawable-xxhdpi/drawable-sw360dp-xxhdpi/drawable-sw360dp-notlong-xxhdpi(when 768x1280 is used)
layout-sw360dp
Resolution 720x1280
values-sw360dp-xhdpi
drawable-sw360dp-xhdpi
layout-sw360dp
Resolution 768x1280
values-sw360dp-notlong-xhdpi
drawable-sw360dp-notlong-xhdpi
layout-sw360dp
Resolution 540x960
values-sw360dp-hdpi
drawable-sw360dp-hdpi
layout-sw360dp
Resolution 480x800
values-hdpi
drawable-hdpi
layout-hdpi
Resolution 320x480
values-mdpi
drawable-mdpi
layout-mdpi
Resolution 240x320
values-ldpi
drawable-ldpi
layout-ldpi
tags to add in manifest if your app needs to support full hd device only
for 1080x1920
<screen
android:screenDensity="480"
android:screenSize="normal" />
Courtesy: (Maulik Joshi)

Related

Refactoring drawable folders from 'large' to 'sw123dp'

The previous dev on this project made all of the drawable folders based on large or xlarge. We've refactored layouts and values to utilize the 'sw' folders. how would the drawable folders for large and xlarge map out?
here's the folders in question:
drawable
drawable-mdpi
drawable-hdpi
drawable-xhdpi
drawable-xxhdpi
drawable-xxxhdpi
drawable-large
drawable-large-hdpi
drawable-large-xhdpi
drawable-large-xxhdpi
drawable-large-xxxhdpi
drawable-xlarge
I'd like to keep the handset folders as-is (the ones NOT tagged with large or xlarge) but convert the others to sw folders. Anybody know the correct sw equivalents for those folders?
From this link, we see that:
hdpi: High-density screens; approximately 240dpi.
xhdpi: Extra-high-density screens; approximately 320dpi. Added in API Level 8
large: Screens that are of similar size to a medium-density VGA
screen. The minimum layout size for a large screen is approximately
480x640 dp units. Examples are VGA and WVGA medium-density screens.
As far as smallestWidth or sw, it says the following:
Some values you might use here for common screen sizes:
320, for devices with screen configurations such as:
240x320 ldpi
(QVGA handset)
320x480 mdpi (handset)
480x800 hdpi (high-density
handset)
480, for screens such as 480x800 mdpi (tablet/handset).
600,
for screens such as 600x1024 mdpi (7" tablet).
720, for screens such
as 720x1280 mdpi (10" tablet).
Edit:
The order in which a drawable is labeled with suffixes is important. For example:
In this case, drawable-large-hdpi will pick the
large attribute first, meaning that its pixel density approximately 480*640 dp units. Then,
hdpi is approximately 240dpi. Android will use hdpi based on the device dots per inches of the device running.
I believe that 480*640 will translate to layout-sw600dp, screen with smallest width of 600dp. Usually for tablets with screen of 7 inches in diagonal measurement.
For safety measures, you can create a folder under layout-sw600dp-hdpi and layout-sw600dp-xhdpi and test it and see how it runs on hdpi and xhdpi tablets.
Note:
Keep in mind that developers who created the previous folders e.g: drawable-large-hdpi may have put whatever they wanted in wherever. So it does not mean that an image within drawable-large-hdpi is surely of 480*640 dimensions and is only for hdpi devices.

how to know which phone support which layout(hdpi , mdpi and xhpi)?

I'm a little confused about how to determine which phones support what layout types. I've done some research but haven't found a satisfying answer.
For example, I've found the below guide:
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
However, I still have some concerns:
Samsung grand (480*800) and HTC wild fire S (320*480) both support MDPI. These screens have very different resolutions, yet have the same layout type?
Galaxy note 2 (1280*720) support HDPI. If HD (720p) is only HDPI, when what device/resolution supports XHDPI?
I've already asked a related question here: How to set layout on 7" two different tablet?.
My most important question, however, is this: How do I know which devices or screen resolutions support each layout type?
Android treats mdpi (160 pixels/inch) as the base density. So for mdpi devices, 1 dp = 1 pixel. At higher densities, there are more pixels per inch (240 for hdpi, 320 for xhdpi).
AutoMatic Scaling by Android itself:
Android attempts to make graphic images occupy the same physical dimensions on the screen regardless of the device pixel density. So if all it finds is an mdpi resource, and the device is hdpi, it will scale the graphic by 240/160 = 150%, and it will double the size of the graphic for xhdpi.
Using different versions of graphics :
If you don't want this automatic scaling (which can make graphics look poor), you can simply supply your own version of graphic resources for use at higher densities. These graphics should be of the same size that Android would scale an mdpi resource.
Note : the pixels/inch that was stored in the image file has nothing to do with this. It's all based on where you put the graphics files in the resources directory for your project. Any graphics placed in res/drawable are assumed to be properly sized for mdpi displays, as are graphics placed in res/drawable-mdpi. Image files that it finds in res/drawable-hdpi are assumed to be properly sized for hdpi displays, etc. When your program runs on a particular device, Android will first look for a graphic that matches the display density of that device. If it does not find one but instead finds one for a different density, it will use that and automatically scale the image based on the above rules.
As the ldpi, mdpi and hdpi refer to screen density, which means how much pixels can fit into a single inch.
the ratio in pixels between them is:
ldpi = 1:0.75
mdpi = 1:1
hdpi = 1:1.5
xhdpi = 1:2
xxhdpi = 1:3
so lets take an image with about the size of 100X100:
for mdpi it should be 100X100
for ldpi it should be 75X75
for hdpi it should be 150X150
for xhdpi it should be 200X200
for xxhdpi it should be 300X300
this way, for screens with the same size but different DPI, all the images seem the same size on screen.
look into these details: android manages all this by itself, you just have to provide layouts and images in relative folders
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

different layout parameters for different devices

I have created a layout in my xml file and have a LinearLayout that is displayed at the top of the activity. I have set its width to fill_parent and its height to 54dp. The height of the layout looks good on devices with bigger screens like Samsung Galaxy, but on smaller devices it looks too big. Is there anyway that the layout will have different height on different screen sizes? I am guessing that this might be achieved by dp, dip, etc. but I'm not sure as to what exactly they do
make layout-normal-hdpi, layout-normal-mdpi and layout-normal-xhdpi folders and copy the same xml in all the three folders than set the different height on each xml as per the devices. This is the standard technique which is been followed. Try this you will surely get desired result.
Hope this will help you...
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
Low density Small screens QVGA 240x320
res/layout-small-ldpi
res/layout-small-land-ldpi
Low density Normal screens WVGA400 240x400 (x432)
res/layout-ldpi
res/layout-land-ldpi
Medium density Normal screens HVGA 320x480
res/layout-mdpi
res/layout-land-mdpi
Medium density Large screens HVGA 320x480
res/layout-large-mdpi
res/layout-large-land-mdpi
High density Normal screens WVGA800 480x800 (x854)
res/layout-hdpi
res/layout-land-hdpi
Xoom (medium density large but 1280x800 res)
res/layout-xlarge
res/layout-xlarge-land
Comment me for any query...

Android screen resolutions

I am following this tutorial link
There three types of screens
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
But there are three folders
drawabale-hdpi
drawabale-mdpi
drawabale-ldpi
I placed images of xlarge in hdpi
that of large in mdpi
and that of normal in ldpi
but where to place the images of small screens?
Sorry for bad english
For example, The following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for small, medium, high, and extra high density screens.
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
and Screen Sizes.
I hope this help.
hdpi, mdpi and ldpi refer to the screen density in dots-per-inch. This is completely separate from the screen size (small, large, etc).
You can have large screen with low density, or a small screen with high density, etc.
You can cater for different screen sizes by putting different layout resources in res/layout-small, res/layout-large, etc.
These are two different things - hdpi/mdpi/ldpi are screen densities (i.e., how many pixels per square centimeter) while xlarge/large/normal/small are screen sizes (the physical dimensions of the screen). So the small screen images would go in drawable-small, normal in drawable-normal, etc.
There's a lot more info about this stuff on the Android developer website.
Screen size has no relation with density. xlarge screen does not mean it has hdpi density. For example tab like galaxy 10.1 pr motorola xoom has xlarge screen but mdpi density so for them you make a separate folder drawable-xlarge. and for this you have to add android:xlargeScreens="true" in manifest.
And devices like galaxy s2 or htc desire has hdpi density. Devices with small screens like galaxy pop are mostly have ldpi density, normal screens like galaxy ace are mostly mdpi devices and devices with large screens like galaxy s2 are mostly hdpi devices, and some devices like tab P1000 have large screens but mdpi density and for them you have to make folder drawable-large-mdpi.

Which layout should I use for HVGA screen?

Which layout should I use for HVGA screen? For a small screen, I put all my XML files in layout-small directory. Similarly for devices like Nexus S and Samsung Galaxy S which have a resolution of 480 x 800. I put all my XML files in the layout directory.
But for HVGA I didn't find any solution. Where to put the XML file for the HVGA device?
Is there any option like layout-small that I can do for HVGA devices? When I run the for HGVA device it takes the layout from the layout directory but as the resolution for HVGA devices is smaller than Nexus S devices, the layout does not properly appear. So I want to know.
To target HVGA 320*480 use:
layout-normal-mdpi
At the same time to support WVGA screens and i.e. Galaxy Tab you need:
layout-normal-hdpi
folders.
According to this
Normal: Screens that are of similar size to a medium-density HVGA
screen. The minimum layout size for a normal screen is approximately
320x470 dp units. Examples of such screens a WQVGA low density, HVGA
medium density, WVGA high density.
MDPI: Medium-density (on traditional HVGA) screens; approximately
160dpi.
You should try: drawable-normal-mdpi
you can use the layout of layout-large
you can refer following link ....
http://developer.android.com/guide/practices/screens_support.html

Categories

Resources