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..
Related
I know the discussion about this is available everywhere and I myself have worked with these folders, but still after reading them I recently I had a big confusion regarding how to arrange images in drawable folders -
Look at this XML File -
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/wallpaper_chapter_selection"
tools:context="com.greenloop.joindotsandpaint.ChapterSelection">
<ImageView android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="#drawable/img2"
android:padding="20dp" />
<RelativeLayout
Let's consider 2 phones regarding this Landscape Mode -
Nexus 10 - 2560 px * 1600px xhdpi
Nexus 5 - 1920px * 1080px xxhdpi
In the case of Nexus 10 - Image size will be 1600px (height)
And in the case of Nexus 5 - Image size will be 1080px
Image size required by Nexus 10 will be greater than that required by Nexus 5, But nexus 10 will take image from the xhdpi folder (smaller image size) as it is xhdpi
and nexus 5 will take image from xxhdpi folder.
So how should I work around this. I have lots of similar layouts in which I am facing a similar problem.
The drawable-hdpi, drawable-xhdpi, drawable-xxhdpi etc. specifies only the dpi dimension and devices of all sizes are going to get resources from the same folder as long as they have the same dpi specifications. To add the screen size dimension you can add large (for devices 7" and around), xlarge(for devices 10" and around) etc. to this. For example you can have a drawable-xlarge-xhdpi to force the Nexus 10" to get a particular resource from this folder. Or your can have only drawable-xlarge and this way all the 10" devices will pull the resources from this folder, no matter what their dpi is.
Basically the one-catch-all is the drawable folder and you overwrite on a case by case basis with the values from drawable-*-*-etc. folders.
Check the part under "Screen size":
http://developer.android.com/guide/topics/resources/providing-resources.html
You can (or rather need to) create different layouts for different screen sizes. Phones and tablets are treated differently.
The Nexus 5 has a higher DPI. 1080px on 5" VS 1600px on 10"... So it is correct that Nexus 5 uses the xxhdpi resource (here: image!) and Nexus 10 the xhdpi. (xhdpi isn't "bigger" than xxhdpi, it just "has less" pixel per inch).
Layouts for phones and tablets are something different to DPI of screens.
I am writing an Android app to have a matrix of image buttons. I tested it with 2 devices: Galaxy Note 1 (5.3") and Galaxy tab 8.0 (8.00 "). When the source images are put in different density drawable folders, both devices took the images from hdpi folder. However the screen sizes are different. Buttons displayed correctly on tab 8.0 but too big on Note 1 (buttons are not all shown).
In this case, what is a better approach for this. Thx a lot.
Galaxy tab 8 is kind of tablets & its density as Galaxy Note one so you should put Galaxy tab image in
// 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
reference : this answer
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.
I have a quick question regarding Android resolutions and how it is represented on the emulator. I have set up a test project to test many different resolutions and how they look on each orientation. So I have created drawable-land-ldpi,mdpi,hdpi-xhpdi and done the same thing for drawable-port. I also have all the layout folders, i.e. small med large x large, small-land,med-land,large-land, x-land
I have created 8 test images, that just say small port, land, medium port, land etc and so on just to check Android is choosing the correct image. I have also created a layout file for each layout folder, in the layout files I have a text field which just specifies the folder name so I know which layout folder is being used.
I have two questions, first is am I creating the correct image size for each folder. The image sizes I have created as are follows
drawable-land-ldpi - 320 * 240
drawable-port-ldpi - 240 * 320
drawable-land-mdpi - 480 * 320
drawable-port-mdpi - 320 * 480
drawable-land-hdpi - 800 * 480
drawable-port-hdpi - 480 * 800
drawable-land-xhdpi - 1080 * 720
drawable-port-xhdpi - 720 * 1080
And my second question is why do these not seem to represent properly on the emulator? Example, I have created an Android app with one screen and the images in the appropriate folders. I have created two emulators, one is 2.3.3, and one is a 3.0 tablet.
If I run the device on my device which, it uses the image from the medium resolution folder and uses the medium layout folder. So if it is port it will use the layout from the default layout folder and the image from the drawable-port-mdpi and if its landscape it will use the layout from the default land folder and the image from the drawable-land-mdpi.
However if I run this on the emulator, on the 2.3.3 device, it uses the layout folder from the medium layout folder, but the image from the drawable-hdpi-port and if its landscape uses the medium landscape layout folder, but the image from the drawable-hdpi-land. If I run it on the 3.0 tablet emulator, it uses the correct layout from the xLarge port and xLarge land, but it uses the image from the drawable-mdpi folders.
I have set up in the manifest to support all resolutions and layouts. Is there any reason why the emulator is doing this? I don't have an Android tablet on me at present to test this as friend forgot to bring it, so I can't test if this works fine on the tablet yet.
I would like to be able to use the emulator to try out a range of devices to test, but if it is not choosing the correct image then I cannot rely on it. Anyone else have issues like this? Or am I doing something wrong?
Any information would be much appreciated!!
Pixel density matters. For instance, your hdpi images may be the right size, but with an incorrect pixel density, they will still get scaled in those folders. For instance, your hdpi images should have a pixel density of ~240dpi. Check the developer guide for supporting multiple screen sizes:
http://developer.android.com/guide/practices/screens_support.html
Another issue is that the screens may be a variety of sizes, along with different pixel densities, e.g., a tablet could be 10 inches (X-Large), but still have a medium pixel density (1280x800). At the same time, you could have another tablet that's also 10" with xhdpi, if the resolution was something like 2560x1600.
It might be better for you to specify your actual layout folders based on pixel density. i.e., you can make folders:
res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)
And you can still apply port and land to them. Read up on the page about supporting multiple screen sizes, it will probably really help to answer a lot of your questions.
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.