Supporting resources for tablets and mobiles - android

I need to support an application for bith mdpi, hdpi and xhdpi mobiles and 7' and 10' tablets I have to admit that I'm a bit lost.
So far I only did the tablet version and what I did is :
one single folder called "layout"
3 different folders called "drawable-sw600dp", "drawable-sw800dp" and "drawable-sw1200" containing images of 600px large, 800px large and 1200px large.
I have the impression that I messed it up and that I should have the created standard "drawable-mdpi", "drawable-hdpi" and "drawable-xhdpi" folders.
But if I do so :
in which folder do I have to put the images for the tablets? xhdpi only?
how large (in px) should be the images for the tablets?
how large should be the images for the mobiles?
and last but not the least : how to have to name the "layout" folders to have a different version for mobiles and tablets?
I already read the Android recommendation like a 1000 times and I am still confused...
EDIT 1
This paragraph from Android website answered my question "how to have to name the "layout" folders to have a different version for mobiles and tablets?"
EDIT 2
Regarding the drawable folders, for mobile phones, it seems quite clear that I have to create 3 folders this way :
drawable-mdpi containing 320px-width images
drawable-hdpi containing 480px-width images
drawable-xhdpi containing 720px-width images
Still remains the question of how to name the different drawable folders for supporting tablets.

so this would be my answer.
Layouts -> 2 folders :
"layout" (or "layout-sw320dp") for mobiles
"layout-sw600dp" for tablets
Drawables -> 5 folders :
"drawable-mdpi" for mobiles, containing 320px-width images
"drawable-hdpi" for mobiles, containing 480px-width images
"drawable-xhdpi" for mobiles, containing 720px-width images
"drawable-sw600dp" for 7'' tablets, containing 600px-width images
"drawable-sw720dp" for 10'' tablets, containing 720px-width images
Any better response than this one is welcome!

Because LDPI is barely used you should make 3 different sizes of images for mobiles.
Lets say you have an image which is 50x50 DP.
MDPI = 50x50PX
HDPI = 75x75PX (x1.5)
XHDPI = 100x100PX (x2.0)
You can create even more folders like: drawable-xlarge-xhdpi and drawable-xlarge-hdpiand put images you need for the tablets in there. I believe xlarge was for 10-inch? So you might end up with about 9 different sizes. 3 for mobile, 3 for 7' and 3 for 10'. Tablets also have pixel densities!
Right click your project in Eclipse -> New -> Other -> Android XML File
And then you choose Drawable as a recourse type to make drawable folders for example.
Below is a screenshot of how this looks. It's really useful!
Also see list of displays by pixel density
Using this you make folders that will look like this. large is 7', xlarge was 10' (I think).
/res/drawable-large-mdpi
/res/drawable-large-hdpi
/res/drawable-large-xhdpi
/res/drawable-xlarge-mdpi
/res/drawable-xlarge-hdpi
/res/drawable-xlarge-xhdpi
7 inch Android tablets are HDPI and large.
Check the table here and read about large/xlarge/small etc.

Related

Supporting different screens for android

This is my first time working with multiple screens. I want to build my application for multiple screens i.e from sw320dp to sw720dp. I have created the following layout folders.
res/layout-sw320dp
res/layout-sw360dp
res/layout-sw480dp
res/layout-sw600dp
res/layout-sw720dp
I have copied all the xml files inside these folders. Is there anything else I need to add to make sure all the layouts support multiple screens. I have gone through the android documentation but I am not clear with the manifest.xml part. If anyone implemented multiple screen support in their application, so please do provide a description and implementation of the same.
Step 1 -You have to create different values folder for Different values for different screens.
Go to Your Project / app / src / main / res.
Right click on res and create different values folder in it.
Step - 2. Create folders named
values-large
values-small
values-sw320dp
values-sw320dp-hdpi
values-sw320dp-xhdpi
values-sw320dp-xxhdpi
values-sw480dp
values-sw600dp
values-sw720dp
Step - 3. Create dimensions.xml file in values folders.
Different values for different screen size.
values-ldpi 2.7" 240*320 ldpi
values-ldpi 3.3" 240*400 ldpi
values-ldpi 3.4" 240*432 ldpi
values-mdpi 3.2" 320*480 mdpi
values-hdpi 4.0" 480*800 hdpi
values-hdpi 3.7" 480*854 hdpi
values-xhdpi 4.7" 1280*720 xhdpi
values-xhdpi 4.65" 720*1280 xhdpi
values-sw480dp 5.1" 480*800 mdpi
values-sw480dp 5.4" 480*854 mdpi
values-sw600dp 7.0" tablet 1024*600 mdpi
values-sw720dp 10.1" tablet 1280*800 mdpi
when you attach dimension.xml file with your layout than you will get direct effect with your screen size.
This will help you to set dimensions for all type of screens.
There is a difference between supporting multiple screen sizes and creating different layout.xml files for each screen size.
In all the apps I've ever worked on, there were really only three different kinds of screens we cared about: small phones (years-old devices that our users weren't upgrading), "regular" phones (e.g. modern-day Samsung or LG phones etc), and tablets. Even considering those three kinds of screens, we often didn't need to create more than a single layout.xml file for a single screen.
If you have just one layout.xml file, it will display itself on any screen size. To "support" multiple screen sizes, you just need to make sure that your content looks good on short phones and tall phones, on wide phones and narrow phones, on phones and tablets, etc. This generally comes down to using dimensions like match_parent, or layout_weight to fill available space, etc.
It is only when you actually need to change what elements are on screen (as opposed to how big elements are) that you need to create extra layout.xml files. For instance, perhaps you know that a certain set of text + images just won't fit on smaller phones. Then you can create one res/layout/layout.xml that has only the text, and another res/layout-sw360dp/layout.xml that has the text + the image. Or maybe you have some content that you want to display side-by-side on a tablet, but you only want part of it on phones. Then you can make one res/layout/layout.xml with the normal content and one res/layout-sw600dp/layout.xml with the tablet-only content.
Regardless, when you decide that you do want to make multiple versions of a layout for different screen sizes, the only thing you have to do is create copies of your layout.xml in different layout-swXXXdp folders. Don't bother with layout-large unless your app supports really old API levels; the swXXXdp method is much more accurate and solves the same problem (but was only added in API 13).
Hey you dont need to do anything in manifest.
You have done the part with layouts.
Next you can do is to add support in drawable folder i.e. different density images for different sizes.
And if different screens require different values(dimentions etc) you need to create multiple file in values.

Different sized images (with the same name) in one drawable folder

I'm new to android programming and every single somewhat-similar question is from three or so years ago and doesn't really answer my question. Android Studio used to have different drawable folders for different dpi. Now there is only one. So if I have two images with the same name but for different dpi, where do I add them so that during runtime the phone can use the appropriate image?
Also, most android phones now are xhdpi or xxhdpi--do I really need to include any images less than that? And how exactly would I do that? Say, for example, that I get an image off shutterstock. How do I make it so it works correctly for both xhdpi and xxhdpi?
Those folders have not gone anywhere, if you want them you simply create a new folder and name it appropriately ( drawable-xxhdpi etc.. )
Depending on IDE it just does not make them by default under certain circumstances
DENSITY SIZE LOCATION RATIO SCREEN MARGIN
XXXHDPI 192×192 drawable-xxxhdpi 4 640 DPI 12 to 16 pixels
XXHDPI 144×144 drawable-xxhdpi 3 480 DPI 8 to 12 pixels
XHDPI 96×96 drawable-xhdpi 2 320 DPI 6 to 8 pixels
HDPI 72×72 drawable-hdpi 1.5 240 DPI 4 to 6 pixels
MDPI 48×48 drawable-mdpi 1 160 DPI 3 to 4 pixels
MDPI 48×48 drawable (Cupcake) 1 160 DPI 3 to 4 pixels
LDPI 36×36 drawable-ldpi 0.75 120 DPI 2 to 3 pixels
NA 512×512 Google Play NA NA As required
Android Studio used to have different drawable folders for different dpi.
It still does.
Now there is only one.
No, there are several. However, in the "Android" project view, they are shown in a collapsed state:
If you change the drop-down towards the top-left of that screenshot to "Project", you will get the view that you are used to, that mirrors the filesystem:
So if I have two images with the same name but for different dpi, where do I add them so that during runtime the phone can use the appropriate image?
The same place as before. Personally, I find the "Android" project view to be singularly useless, and so I switch to the "Project" view as one of the first things when I open the project.
most android phones now are xhdpi or xxhdpi
No, right now, only about a third are.
do I really need to include any images less than that?
I would. If you have a zillion drawables, you are welcome to experiment with having fewer densities, but you will want to test the lower densities to confirm that the downsampling of your drawables is turning out OK.
Create the folders yourself as you need them. It's true that most phones now are xhdpi but what about your target audience? Are you sure their phones and tablets support xhdpi at minimum? There are some tablets such as the Galaxy Tab 2 which are below these values. Just something to keep in mind. Although, consider using layout-sw(x)dp for devices bigger than 600dpi
You'll have to resize them for the appropriate drawable. Use you should follow the 3:4:6:8:12:16 scaling ratio where 48x48 is the baseline. As an example, in order to support xxxhdpi your drawables would be 192x192
Actually Android Studio also has multiple drawable folders. But It remains wrapped in Project Structure's Android View.
So you see only one Drawable folder.
If you want to see all the drawable folders in expand mode then click on the drop down like below and select "Project":
Now you can navigate the drawable folders like this:

Drawable folder for 8 inch tablets

I am working in an android application and I want to support my application in all devices. But I don't know from which drawable folder 8 inch tablet takes images.
"drawable-mdpi" for mobiles, containing 320px-width images
"drawable-hdpi" for mobiles, containing 480px-width images
"drawable-xhdpi" for mobiles, containing 720px-width images
"drawable-sw600dp" for 7'' tablets, containing 600px-width images
"drawable-sw720dp" for 10'' tablets, containing 720px-width images
???? for 8'' tablets
You can use : "drawable-sw720dp" for 10'' tablets, containing 720px-width images" for the 8" Tablet .
For more info you can refer here , as 8" is reside between 7-10 Range so that you can use 10" drawable folder
http://developer.android.com/guide/practices/screens_support.html
"drawable-sw600dp" for 7'' tablets, containing 600px-width images
"drawable-sw600dp" is the folder that applies the drawable properties of device with minimum 600dp width.
So you dont need to worry about it.The android system will automatically suites drawable from sw600dp to 8 Inch Tablets
Have a Nice Day ....
The qualifiers hdpi,xhdpi,xxhdpi describes the screen density of the device, not the size of screen. From the official doc
The better practice is to put the following drawables
// for Phones
drawable-ldpi
drawable-mdpi
drawable-hdpi
//for 7 inch tablets
drawable-large-mdpi
drawable-large-hdpi(for Nexus 7)
// for 10 inch tablets
drawable-xlarge-mdpi
The drawable for 8" inches should be implemented if the App uses large background images where should be taken in a serious importance for memory allocation.
U can easily categorize your Drawables to large-mdpi, large-xhdpi , large-port-xhdpi(..) but u are in a situation where u delete the small , normal large and u implementing a swallest width of 600, 720 as any android delevopers will customize early or later.. I really suggest to implement an sw800 where has 1280 x 800!!! and also to make sure in your code to have an ifstatement where directly speaks throw the DisplayMetrics.Density and implements == to 800 widthPixels... This will give an HD performance if the images are recycling and are on in InBitmap to retain instance..

Having bigger images for a xlarge screen in android

I am building an android application on version 2.2, I need to support for extra large screen. Layout rendering is no problem, but there are some devices which are extra large but are mdpi.
It is taking all the drawables from drawable-mdpi, I want my layout to take bigger images for xlarge screen, I have even defined drawable-xlarge for loading bigger images but still the images are getting loaded from drawable-mdpi folders.
My other drawable folders are
drawable-ldpi which has images of dimension of 32 by 32.
drawable-mdpi which has images of dimension of 48 by 48.
drawable-hdpi which has images of dimension of 72 by 72.
drawable-xhdpi which has images of dimension of 96 by 96.
then for extra large screens I have drawable-xlarge which has images of 108 by 108.
How to make android load bigger images for xlarge screens. App is not getting loaded with images from drawable-xlarge, are there any changes I should carry out to get bigger images loaded into xlarge screens rather than from drawable-mdpi folder.
Any help or pointers would be helpful.
thanks.
You will probably have to provide several other more specific qualified resource folders, such as drawable-xlarge-mdpi. Going by the information in Providing Resources, it should work the way you have it (i.e. screen size qualifiers should take precedence to density qualifiers) but it seems that for you it isn't working as expected. Are you certain it's an xlarge display? If so, I would try placing your images into res/drawable-xlarge-mdpi.
look it will be better if you make separate layout for x-large screens refer supporting multiple screens from android developers site
as the android system will fetch images from mdpi,hdpi,ldpi or xhdpi according to the screen density not according to the size

android layout on different screen sizes

i have an application that am trying to implement it on a tablet 7'. this that i have done is the follow. on the folder drawable and layout are my defaults for the normal smartphone screen. also i have create the layout-xlarge and drawable-mdpi in which on the first one i have change the sizes and on the second one i add the images with different size. my problem is that the default get the size of images that i have on the drawable-mdpi folder and not from the default drawable folder. what am i doing wrong? also i have nothing declare on the manifest.
mdpi is the default, so drawable and drawable-mdpi are the same thing and I don't know which Android chooses in this case - but you're designing for a tablet and tablets are generally mdpi devices so it correctly gets it from drawable-mdpi. You could use drawable-xlarge-mdpi if you want separate mdpi resources to be used for extra-large screens. Incidentally, remember a 7" 1024x600 tablet is large, not xlarge - so try drawable-large-mdpi and layout-large-mdpi and see if that gives you what you want.

Categories

Resources