Android interface implementation for multiple screen sizes and densities - android

I'm developing an application and i need it to fit all screen sizes and densities.
I created 4 folders for the resources (drawable-ldpi,drawable-mdpi,drawable-hdpi,drawable-xhdpi) and 4 xml layouts. But i'm confused a little about many points:
1- If I have a Samsung Galaxy tab 10.1 (mdpi screen) with a 1280 x 800 screen size and a Samsung Gio (mdpi screen) with a 320 x 480 screen size, how can I make the "layout-mdpi" folder including the xml layout file for medium dpi, fits these 2 devices having the same dpi but 2 different screen sizes (Galaxy tab is much bigger than Samsung Gio)?
2- I'm creating my png's using Photoshop, these png's must be saved with 320dpi,160dpi,240dpi..? Or all the resources must be saved in 72 dpi but different sizes?
3- I tested a star icon on my Samsung Galaxy tab 10.1 (mdpi screen) having 32x32px size, dunno why my icon is blurred!

You have to make all 4 different sizes images and put that images according to folder.And also set the property in menifest like this.
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />

Related

Supporting multiple screen size

I've used several images with different sizes. I copied the images into different folders.
such as (except drawable-ldpi folder):
for example :
drawable-mdpi test.png => 60*60 px
drawable-hdpi test.png => 85*85 px
drawable-xhdpi test.png => 110*110 px
drawable-xxhdpi test.png => 110*110 px
I have only one folder my layouts:
my manifest:
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
now, when I install my project on galaxy s4, images within the program shows drawable-mdpi folder. why ?
I even made ​​a separate folder for my layout and changed width and height of image :
res/layout/my_layout.xml imageview => layout_width and layout_height = 48*48 // default
res/layout-large/my_layout.xml
res/layout-xlarge/my_layout.xml
But always the default option is selected ! why?
you don't need to write support-screens in the minifest - default is fine.
first things first:
s4 is on the upper end of normal but it should still be normal not large. this is why your 'layout-large' was not used. but you should not use the size selection stuff, dpi selection is much better (so one layout should work).
s4 is on the edge between xxhdpi and xhdpi so samsung can decide what it is. i think they used xhdpi. but this should not realy matter.
dpi categories:
ldpi (you will not need it because neerly no device has it)
mdpi = 160dpi or 1x
hdpi = 240dpi or 1,5x
xhdpi = 320dpi or 2x
xxhdpi = 480dpi or 3x
simple dpi example:
if you have a fullscreen design/image in full hd (1080x1920) you can just cut the stuff out as you need it and will get it correct for xxhdpi. (if i remember correct - maybe xhdpi)
however, you can calculate the lower sizes from this point.
- xxhdpi = 1080x1920
- xhdpi = 720x1280 (/3*2 of the above)
- ...
if you do it this way it should work correct ;)

Android - Setting for Tablets

I am pretty new to Android. I wanted to know that if i want to design a tablet application then what changes i want make in the existing code which i designed for normal phone.
I did the Research and found,
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 in Manifest
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
Is it all done?? or I want to change something other than this??
You need to create new layout files for tablet versions, Java part is enough but layouts and image drawables are the main things you need.
Go through Supporting Multiple Screens, Here you will have a complete idea about how to create UI supporting Tablets and their res folders.
For all tablet resolutions check this link
below are the available resolutions for android mobile and tablet
1 2560*1600
2 1366*768
3 1280*800
4 1280*768
5 1024*768
6 1024*600
7 960*640
8 960*540
9 854*480
10 800*600
11 800*480
12 800*400
13 640*360
14 640*240
15 480*320
16 400*240
17 320*240
Most Common tablet resolutions are
Samsung Galaxy Tab 10.1 3G - 10.1 inches, 1280 x 800 pixels
Samsung P1000 Galaxy Tab - 7.0 inches, 600 x 1024 pixels
For application to be worked, this is enough. But you should take care the size of the application When you are adding images to drawable folders it will increase your project size. So if you are using same images for all screens put that image in drawable folder. It will pick automatically to all screens, and if you want different image for different screen size put in different layout folders. You can make different layouts according to screen size to be fitted. The android will automatically pickup the proper xml files.
add layout-large-hdpi folder to ur resources and copy the files from layout to created one,
all ur created layouts will automatically converted to tablet screen size

Multiple Screens Android

I'm developing an app in android and I have to support many different screen sizes and density. So i've created different a folder for layout : layout and layout-large.
For a normal screen size I have these drawable folders: mdpi(with a 320x480 image in it), hdpi (with a 480x800 image in it), and xhdpi (with a 640x960 image in it), but I also need a mdpi for a xlarge size screen. Should I create a drawable-large-mdpi and then put my image (480x800) in there?
Anyways I tried to do that and it seems to work just fine.
On my manifest I have:
<supports-screens android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"/>
I'm using three different emulators:
4.0" WVGA (480X800: hdpi),
3.2" HVGA slider (ADP1) (320x480:mdpi), and
5.1" WVGA (480X800: mdpi)
My problem is that when I run it the size of the screen never match in any of the emulators. The width seems to get a bit smaller. It is never 100%
In the AVD manager when you start your AVD manually you get Launch options, there put a check mark against scale display to real size.
Setup your monitors dpi by clicking on the question mark.
Enter the monitor screen size and monitors resolution and then click on ok.
Now enter the screen size for your emulator in inches and then click on launch.
Do the same for all three emulators your testing the app against.

Android 2.2 - screen resolutions and sizes issue

The android version is 2.2. And the apps will not support drawable-xhdpi with drawable-xlarge folder. However, i have met many issue when I am processing different screen size from different mobile.
The first problem is that I want to know what is the situation that android will load correct image from drawable-ldpi, drawable-mdpi, drawable-hdpi folder? There are one image in each folder (drawable-ldpi, drawable-mdpi, drawable-hdpi).
(1) 240px x 150px for drawable-ldpi
(2) 320px x 200px for drawable-mdpi
(3) 480px x 300px for drawable-hdpi
But why i cannot see correct image if the output device width screen is 480px? The output device only shown 320px width image. Not the 480px image. The issue seems that what the thing i have missing?
Then, i renamed all drawable folder to drawable-small, drawable-normal, drawable-large. It is working that drawable-large can display 480px width image. Will it be good if i do this way?
The second issue is that some samsung device have got different screen resolutions, i would like to know how to support these screen resolution as I want to make 800px width screen displays 800px width image, 900px width screen displays 900px width image? Any method can do different screen resolution? Many people said the folder drawable-xhdpi can solve issue that image can be auto-scaling. I cannot see any image can be auto-scaling. Maybe i have missing some steps.
Kindly advise.
Thanks a lot.
I will try to give you better insight into this.
Screens can be divided into more or less 4 different categories:
Low-density
medium-density (Baseline)
high-density
extra-high-density
You also get xxhdpi these days...
low-density = ldpi (120dpi)
medium-density = mdpi (160dpi)
high-density = hdpi (240dpi)
extra-high-density = xhdpi (320dpi)
Another good example comes from the android developer pages:
http://developer.android.com/images/screens_support/screens-ranges.png
You can find a list of devices and their pixel densities here:
h ttp://en.wikipedia.org/wiki/List_of_displays_by_pixel_density
h ttp://checkscreensize.appspot.com/listdevice.jsp
You will always be designing apps with multiple layouts/drawables to support different devices. Not just Samsung devices, but most brands have different devices with different pixel densities and resolutions.
In short, by providing multiple resources, android will choose the correct one to best fit the current device and if it does not find one in a certain layout or drawable folder, it will simply use the next best layout/resource with that name.
Note, this is to avoid stretching and incorrect scaling of drawables and layouts.
How to support multiple layouts ?
in your manifest file.
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
Provide different layouts or drawables for different screen sizes.
Now, there are multiple ways of doing this and some ways are dependent on the sdk level.
Pre Android 3.2 / API 13 , use layout-small/normal/large/xlarge.
After Android 3.2 / API 13 , use layout-hdpi, or layout-sw600dp etc.
Here is the official table of qualifiers you can use, by placing a dash between them:
http://developer.android.com/guide/practices/screens_support.html#qualifiers
Generally, I think that you will only design for landscape mode with tablets, therefore, you could consider using only these and:
layout-ldpi
layout-mdpi
layout-hdpi
layout-xhdpi
layout-large
layout-large-land
layout-xlarge
layout-xlarge-land
and for your drawables:
drawable-ldpi
drawable-mdpi
drawable-hdpi
drawable-xhdpi
Further, by default, I currently choose to design for 6 different devices that overall fits best in the profiles ldpi, mdpi, hdpi, xhdpi for phones (4) and tablets (2):
Samsung Galaxy S3 (720x1280, xhdpi, Normal screen size)
Samsung Galaxy S2 (480x800, hdpi, Normal screen size)
Samsung Galaxy Ace Plus (320x480, mdpi, Normal screen size)
Samsung Galaxy Mini (240x320, ldpi, Normal screen size)
Samsung Galaxy Tab 10.1 (800x1280, mdpi, X-Large screen size)
Samsung Galaxy Tab 7.0 (600x1024, hdpi, Large screen size)
Designing for these devices ensures that the app will work great on most other devices aswell.
Hope this information helped.

support different screen sized

I have a project for an application that can run on different types of android device:
-small device :example samsung ace
-normal device:samsung galaxi s3
-tablet 10''
My layout is complex and the use of match_parent and "dp" isn't enough. I have read: http://developer.android.com/guide/practices/screens_support.html but I did not understand all of it.
Will I have to create more XML's in say, res/layout-sw720dp/main_activity.xml folder ow will I have to use different qualifiers? How exactly does it work?
For Different screen size, The following is a list of resource directories in an application that provides different layout designs for different screen sizes.
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
The following code in the Manifest supports all dpis.
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
Kindly Use This qualifier for your Android Project with compatible screen size.
Resource Screen Size
layout-small <3 inch
layout-normal 3-4 inch
layout-large >4 inch<7.1
layout-xlarge 7.1 - 10.1 inch
If you still facing problem use this Tutorial Link
If you want to create 1 application for different devices then you have to use android different folder as defined in the sdk
for e.g
drawable-ldpi - to place the images for the low screen density devices(240*320)
drawable-mdpi - to place the images for the middle screen density devices(320*480)
drawable-hdpi - to place the images for the high screen density devices(480*800)
drawable-xhdpi - to place the images for the extra high screen density devices (above 480*800)
If you want to create application for the tablet
drawble-sw720dp - to place the images for the tablet devices(7")
drawable used to place images. you have to create the layout for different drawable folder
layout-ldpi - to place the layout for the low screen density devices(240*320)
layout-mdpi - to place the layout for the middle screen density devices(320*480)
layout-hdpi - to place the layout for the high screen density devices(480*800)
layout-xhdpi - to place the layout for the extra high screen density devices (above 480*800)
android automatically get the images and layout from the application according to the device density. but for this you have to define
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
so that application develop for the multiple screen resolution devices.
To develop an application which supports every density and resolution, we should keep following points in mind:
(1) Put different sized images(with the same name) in 4 different folders in the ratio:
ldpi : mdpi : hdpi : xhdpi = 3 : 4 : 6 : 8
(2) The sizes commonly used for these resolutions are:
ldpi = 36 * 36 px mdpi = 48 * 48 px hdpi = 72 * 72 px xhdpi = 96 * 96 px
But you can use your desired sizes for the images as well.(Just try to follow the ratio in different sizes as well.) Amongst of all these images, the image which suits the device's density , will automatically be picked.
(3) Besides this, you can also get the density of the device programmatically and set the layout accordingly, like this:
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
switch(displayMetrics.densityDpi){
case DisplayMetrics.DENSITY_LOW:
// layout for small sized devices.
break;
case DisplayMetrics.DENSITY_MEDIUM:
// layout for medium-sized devices.
break;
case DisplayMetrics.DENSITY_HIGH:
// layout for big-sized devices.
break;
}

Categories

Resources