I have a background image of different sizes, 240x320, 320x480, 480x800, 1024x600, 1280x720. I have a drawable-large-mdpi folder that holds 480x800 image, which I use in layout-large and it seems to fit well for screens 5.1", 5.4". From my understanding, layout-large is for screens ranging from 5.1" to 7.3". My question is how to provide a different image of dimension 1024x600 for 7" tablet? Which drawable folder holds this(1024x600) image that i can make use of for 7" tablets?
How could I store 480x800, 1024x600 images in the same folder with same name so that the former can be used on 5.1", 5.4" devices and the later for 7" tablets?
In Eclipse, AVD manager Device Definitions, 5.1", 5.4", 7" devices are specified as Large mdpi. Can i place 1024x600 image in drawable-large-mdpi folder that might scale down for 5.1" and 5.4" devices?
Please help me out. I'm pretty much confused about it.
for 7 inch tablerts you can use
drawable-large-mdpi
drawable-large-hdpi(for Nexus 7)
Related
I want to provide drawables for:
hvga and qvga phones (but those use hdpi drawables pretty well)
hdpi phones
xhdpi phones
xxhdpi phones
7" tablets
10" tablets
I have folders:
drawable-hdpi (used by phones up to 480x854 screens)
drawable-xhdpi (used by phones like Galaxy S3)
drawable-xxhdpi (used by phones like Galaxy S4)
drawable-sw600dp (I would expect: used by 7" tablets)
drawable-sw720dp (I would expect: used by 10" tablets)
My original problem was, I thought resources from drawable-sw720dp are not used, but they are! Some graphic designer gave me files with different names and I did not notice. My fault.
So no problem at all.
For supporting tablets also, use large, xlarge qualifiers. Nexus 7 is a large-hdpi tablet(technically it's tvdpi, but takes images from hdpi). So if you want to put images for Nexus 7, make a folder named drawable-large-hdpi and put the images there.
Now regarding the 10 inch tablets case, they are xlarge devices and their densities can change from mdpi to xhdpi(Nexus 10). But many have resolution of 1280 * 800 and they are mdpi devices.
Create drawable folder like this
// for Phones
drawable-mdpi
drawable-hdpi
drawable-xhdpi
drawable-xxhdpi
//for 7 inch tablets
drawable-large-mdpi
drawable-large-hdpi(for Nexus 7)
// for 10 inch tablets
drawable-xlarge-mdpi
drawable-xlarge-xhdpi(for nexus 10)
Source of answer
My original problem was, I thought resources from drawable-sw720dp are not used, but they are!
Kindly I want to know why Galaxy S3 and S4 get the images from this folder (drawable-sw360dp-xhdpi)??
all images seem very large for these devices !
also If I make these images smaller they will not be suitable for larger devices !
Please, what is the solution?
I assume you are using layouts for 10 inch and 7 inch devices are layout-sw720dp and layout-sw600dp then you just create drawable-sw720dp and drawable-sw600dp, also in the case of high density for those xlarge and large screen devices then append the corresponding density to the drawable folder . For example use drawable-sw600dp-hdpi for high density 7 inch tablets like ASUS MeMO Pad HD 7'. Now resource for large and xlarge are solved
Now Consider the drawable-sw360dp devices.
drawable-sw360dp/layout-sw360dp are for phablet devices like Note1,Note2, Micromax CanvasHD,S3.
The above mentioned devices are XHDPI devices. For using drawables either you can use drawable-xhdpi or use drawable-sw360dp-xhdpi
Thus you can distinguish resources for s3,s4 from xlarge and large screen devices.
Note : S3 and s4 taking images from drawable-sw360dp-xhdpi because smallest width of those devices are 320dp. You can check the device display information by installing screen info app from the playstore.
check screen info app here
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
http://developer.android.com/guide/practices/screens_support.html
It is based on the dpi
even now there is a xxhdpi folder or I may be wrong on that one??? Some one else to confirm that?
I have both hdpi and xhdpi folders in my res folder. However, android makes use of hdpi xml file for 1280 X 800 resolution of a tablet. Could it be because my xml file accesses resources which are in drawable-hdpi folder but not in drawable-xhdpi folder?
I think you are confused with DPI vs screen sizes, which resolution along does not provide. You can have a XHDPI device with a small screen that is very high resolution (such as the Galaxy S3) or a MDPI or LDPI device with a very large screen (such as when you use Android on your TV).
Generally speaking, Dot per pixel = Resolution / Screen size.
Not all android devices are set to the right density by the manufacturer, its really a hodgepodge of densities no matter what resolution you think you have, the device could still be seen by the android OS as a lower or different density than you think
if the android OS thinks your device is HDPI then it will access HDPI drawables
I am testing on the Android 4.1.1 emulator with the WXGA800 - 7inch version. This has a resolution of 800x1280 with density of 213dpi. I have the following folders
drawable
drawable-h1200dp
drawable-xhdpi
drawable-hdpi
drawable-mdpi
drawable-ldpi
I have the same directory structure for 'layout'
Problem I have is for this 'built in' emulator the drawable-h1200dp resources are not being selected so the images are small. The height is 1280 so this should select the h1200dp should it not or have I got it wrong? If someone could explain
Thanks
you can set the abstract LCD density when you EDIT or CREATE a new AVD, Android cares more about the pixel density rather than the resolution itself when it has to choose what layout it's supposed to pick among the several resources available.
Extract from Android Developer Guide link above:
320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480dp: a tweener tablet like the Streak (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc)
So i got graphics(images) at resolution 320 pixels per inch from designer in these dimension only
480x800 hdpi
720x1280 mdpi
800x1280 mdpi
I am confused which size of images should be placed in mdpi folder, hdpi folder and xhdpi folder. I want to make one application which can work on most android phones and tablets ?
You can create different graphic objects for use at different pixel densities. 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). 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.
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 that 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.
When you request a resource for which you provide alternatives, Android selects which alternative resource to use at runtime, depending on the current device configuration. To demonstrate how Android selects an alternative resource, assume the following drawable directories each contain different versions of the same images:
drawable/
drawable-en/
drawable-fr-rCA/
drawable-en-port/
drawable-en-notouch-12key/
drawable-port-ldpi/
drawable-port-notouch-12key/
And assume the following is the device configuration:
Locale = en-GB
Screen orientation = port
Screen pixel density = hdpi
Touchscreen type = notouch
Primary text input method = 12key
By comparing the device configuration to the available alternative resources, Android selects drawables from drawable-en-port.
The system arrives at its decision for which resources to use with the following logic:
Ref : How Android Finds the Best-matching Resource
Other References : Density independence , Providing Alternative Resources and Best Practices
And I will say that you should read complete page Supporting Multiple Screens, I don't think nothing will be better documentation than it...
I'm confused myself with all the screen size fragmentation but the basics are:
1. You need to create various folders under layouts to work with your images
2. Images will exist in the drawables folders also under various folders.
3. You should have a basic /layout and /drawable folder to accompany non-specific folders
4. Work from xhdpi then scale images down!
Examples for specific screen folders:
/layout-hdpi
/layout-xhdpi
/drawable-hdpi
/drawable-xhdpi
From what I know:
480 x 800 is hdpi (older phones eg S2, HTC Desire etc)
720 x 1280 is xhdpi (new phones eg S3, Galaxy Nexus etc)
Basically, Depending on the phone, android will grab resources from the necessary folder and if there is none then it will grab from the main '\layout' or '\drawable' folder. For example, the app running on a Galaxy Nexus will grab resources from '\layout-xhdpi' if the folder exists.
yes, you can make one app, but was need creating folders: /res/drawable, /res/drawable-mdpi, /res/drawable-hdpi and add content for all screen sizes