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.
Related
I've read so much about these things already, so many threads, but there still some things that I don't understand about how to, as a both developer and a designer, avoid problems with different sized screens.
So my question is mainly: What is the difference between putting drawables into mdpi,hdpi,xhdpi,xxhdpi folders as opposed to normal,large,xlarge folders? Should I do both?
I want drawables to act like this: If it takes 50% of the width of the screen on a smartphone, it should take 50% of the screen on a tablet. That's where I'm also confused - Both my phone and tablet are 1920x1080 and both fall into the xhdpi bucket (I believe), but their physical screen sizes are very much different.
Now I save drawables according to the mdpi, hdpi... ratios. Therefore I get results like this on the phone:
When I just out of curiosity created folders for drawables large and xlarge (I didn't know the ratios), I get this, which is closer to what I'm aiming for (but is obviously too big):
But what's the point of using the xhdpi (etc) buckets? Am I understanding this completely wrong? Someone please enlighten me. I hope this question makes sense. My point is - I want the scales of text and pictures to fill about as much of the screen on a tablet as on a smartphone.
Thanks
We developers just create drawbles for mdpi, hdpi, xhdpi, xxhdpi because screen resolution of devices maybe different. While in the case of the normal, large, xlarge folders it is used for the case of screen sizes.We Use This configuration qualifiers (mdpi, hdpi, xhdpi, xxhdpi) because for example for low budget phone, resolution maybe less and will show 48px drawable bigger while high end devices will show it smaller. That's why we create drawables for different resolutions of phones varying from 42(maybe) to 192 px.Similarly normal,large,xlarge folders are used in respect with screen size.
If you want to compress app size, you may use vector drawables. They are just created for one time and look consistent on every time.For Custom icons, export it to .svg or .psd format and create it as vector drawable through android studio.
Edit : I usually create my logo on Photoshop and android studio efficiently exports it to vector drawable.
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.
Vector drawables are put in drawables folder. There is one more advantage of using vector drawables that is one May animate it.
Note : Beginning with Android 3.2 (API level 13), these size groups small, normal, large,xlarge folders are deprecated in favor of a new technique for managing screen sizes based on the available screen width. If you're developing for Android 3.2 and greater use mdpi,hdpi,xhdpi,xxhdpi folders.
The configuration qualifiers (described in detail below) that you can use for density-specific resources are ldpi (low), mdpi (medium), hdpi (high), xhdpi extra-high), xxhdpi (extra-extra-high), and xxxhdpi (extra-extra-extra-high).
Screen Density of devices
A set of six generalized densities:
ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi
xxxhdpi (extra-extra-extra-high) ~640dpi
Images Sizes as per folders.
36x36 (0.75x) for low-density
48x48 (1.0x baseline) for medium-density
72x72 (1.5x) for high-density
96x96 (2.0x) for extra-high-density
144x144 (3.0x) for extra-extra-high-density
192x192 (4.0x) for extra-extra-extra-high-density. Hope this will help.You ask me more about this in detail in comments.
I've come across with this table showing what Android uses as baseline for screen density:
Here i understand that if my mdpi image is 100px, then i have to use 150px(1.5 factor) for hdpi.
Question 1: Does mdpi targets screen densities between 120dpi screen and 160dpi screen? Because my phone has 432dpi(or ppi) and it uses xxhdpi, so i thought xxhdpi targets screen densities between 320dpi and 480dpi, right?
But here i've came across with different table, showing example:
Question 2: According to assumption above, xhdpi should target between 240dpi-320dpi, but in second table 336dpi is also considered as xhdpi, why? And what happens if user has screen density > 480dpi and i don't have xxxhdpi folder?
Android picks the right density bucket for a given DPI value based on the bucket which has the least difference in DPI value.This can easily be seen in de following image:
Quote:
Figure 1. Illustration of how Android roughly maps actual sizes and densities to generalized sizes and densities (figures are not exact).
Source: http://developer.android.com/guide/practices/screens_support.html#range
Question 1:
Mdpi targets roughly anything between 140 DPI and 180 DPI.
Question 2: 336 DPI is considered xhdpi because the xhdpi bucket is the closest one (in DPI value: 6). The difference to the hdpi bucket is 96 and the difference to the xxhdpi bucket is 144.
When a density folder is missing Android picks the best alternative folder and if needed applies scaling to the resources to match the target density.
I am working on Android application that should support 2.1 till latest Android OS (4.2) version. Currently I have few images to display in my image-gallery module.
I need to support my app on all devices (smartphone and tablet) which support OS ranging from 2.1 to 4.2 (latest).
Each image is roughly of size 368X387, 50 KB each, PNG type
My workspace res contains following drawable folders:
drawable-hdpi
drawable-ldpi
drawable-mdpi
drawable-xdpi
I have some confusion around
In which folder should I store the images, and how will that matter?
Do I need to have different resolution based images for different type of devices?
Thanks.
You can store images only in 1 folder BUT,
for example you have device that is mdpi.. it will look good on him, but if you run your app on ldpi android will automatically scale your image and it will look ugly (low quality). So yea you need different resolution based images for different types of devices..
so mdpi resolution images go to drawable-mdpi
so hdpi resolution images go to drawable-hdpi etcc..
this is some list i found on internet about screen sizes, maybe you will find it helpful:
Low density Small screens QVGA 240x320 (120dpi):
layout-small-ldpi (240x320)
layout-small-land-ldpi (320x240)
Low density Normal screens WVGA400 240x400 (x432) (120dpi):
layout-ldpi (240 x 400 )
layout-land-ldpi (400 x 240 )
Medium density Normal screens HVGA 320x480 (160dpi):
layout-mdpi (320 x 480 )
layout-land-mdpi (480 x 320 )
Medium density Large screens HVGA 320x480 (160dpi):
layout-large-mdpi (320 x 480 )
layout-large-land-mdpi (480 x 320)
Galaxy Tab ( 240 dpi ):
layout-large (600 x 1024)
layout-large-land (1024 x 600)
High density Normal screens WVGA800 480x800 (x854) (240 dpi):
layout-hdpi (480 x 800)
layout-land-hdpi (800 x 480)
Xoom (medium density large but 1280x800 res) (160 dpi):
layout-xlarge (800 x 1280)
layout-xlarge-land (1280 x 800)
Also it would be good to read official documents site about supporting different types of screen.
There are four folder in resource folder 1- drawable-hdpi 2-drawable-ldpi 3-drawable-mdpi
4-drawable-xdpi
To declare different layouts and bitmaps you'd like to use for different screens, you must place these alternative resources in separate directories/folders. This means that if you generate a 200x200 image for xhdpi devices, you should generate the same resource in 150x150 for hdpi, 100x100 for mdpi, and 75x75 for ldpi devices.
Then, place the files in the appropriate drawable resource directory: as per your need
if you want to use same images for all types of screen then you can make an other folder named "drawable" and put all images in that folder. it would work as default drawable.
but if you want to improve image quality on all resolutions. then you need all 4 types images and put then on their respective folder with same image name. you can also make differ XMLs for each resolution.
See this http://developer.android.com/training/multiscreen/screendensities.html
You can put a particular image in all folders.
drawable-hdpi
---->img.png
drawable-ldpi
---->img.png
drawable-mdpi
---->img.png
drawable-xdpi
---->img.png
It all depends on your os .it ll take by default according to device resolution .
In android we have "Res" folder is nothing but resources folder.Inside this res folder we have other sub folders but for storing images we have four types of folders names are called:
drawable-hdpi
for High density screens and its resolutions is 480*800
drawable-ldpi
for Low density screens and its resolutions is 240*320
drawable-mdpi
for Medium density screens and its resolutions is 320*480
drawable-xdpi
for Xtra density density screens and its resolutions is 640*960
If you want to match image for multiple screens my suggestion is to use
Nine patch image rather than .png and .bmp
for creating nine patch image
http://developer.android.com/tools/help/draw9patch.html
I am having this issue where I have HDPI and XHDPI folders in my eclipse project both have different images resolutions, both Images in the different folders are exactly the same but they differ in size.
So I lunched my app on Samsung Galaxy Note 1 which have 800 x 1280 pixels, 5.3 inches (~285 ppi pixel density) display, but it's loading drawables from the XHDPI folder.
I have tested that by modifying one image in HDPI folder and keep it as it is in the XHDPI folder, the result was note 1 is loading from the XHDPI folder, am I missing something here, it suppose to load images from the HDPI folder because it's screen density is smaller than 320 DPI.
You can check what density your device is set to with
Log.v(TAG, "density=" + getResources().getDisplayMetrics().densityDpi);
am I missing something here, it suppose to load images from the HDPI folder because it's screen density is smaller than 320 DPI
The maker of the device chooses which density bucket to use. Since ~285 is closer to 320 than 240, it is not surprising to me that Samsung chose -xhdpi. Others have reported that it indeed is an -xhdpi device.
If you are finding that -xhdpi resources result in slightly too large of images in certain places, you may need to control that in those places (e.g., set the ImageView size to the size that you want and set android:scaleType to be how you want the image to be adjusted).
it suppose to load images from the HDPI folder because it's screen density is smaller than 320 DPI.
why that?
HDPI is 240 ppi
XHDPI is 320 ppi
Note 1 has a 285 which is closer to XHDPI (|285-320|=35) than to HDPI (|285-240|=45)
On Android developer website, it says,
"hdpi Resources for high-density (hdpi) screens (~240dpi).
xhdpi Resources for extra high-density (xhdpi) screens (~320dpi)."
Any device which has a density higher than 240dpi should load layouts and images from xhdpi folder.
Thus, your app on galaxy note which has 285dpi loads images from xhdpi folder.
I am creating an Application which will run on all Android Devices. I want to create xhdpi Graphics for My App. My App is full screen. I am confused in Creating graphics. can any one tell me the best sizes of my background image in pixels.
For Example:
xhdpi: 720x1280 px
hdpi: 480x800 px
mdpi: 320x480 px
ldpi: 240x320 px
Suggest me the best sizes which will appear on all devices good. Because my graphics are the core of my app.
I want that every device get the best image which it want. Android will be not involved in compressing or expanding of image.
The following are the best dimensions for the app to run in all devices. For understanding multiple supporting screens you have to read
http://developer.android.com/guide/practices/screens_support.html
xxxhdpi: 1280x1920 px
xxhdpi: 960x1600 px
xhdpi: 640x960 px
hdpi: 480x800 px
mdpi: 320x480 px
ldpi: 240x320 px
Android Devices Matrices
ldpi mdpi hdpi xhdpi xxhdpi xxxhdpi
Launcher And Home 36*36 48*48 72*72 96*96 144*144 192*192
Toolbar And Tab 24*24 32*32 48*48 64*64 96*96 128*128
Notification 18*18 24*24 36*36 48*48 72*72 96*96
Background 240*320 320*480 480*800 768*1280 1080 *1920 1440*2560
(For good approach minus Toolbar Size From total height of Background Screen and then Design Graphics of Screens )
For More Help (This link includes tablets also):
https://design.google.com/devices/
Android Native Icons (Recommended) You can change color of these icons programmatically.
https://design.google.com/icons/
Check this. This image will show for all icon size for different screen sizes
I looked around the internet for correct dimensions for these densities for square images, but couldn't find anything reliable.
If it's any consolation, referring to Veerababu Medisetti's answer I used these dimensions for SQUARES :)
xxxhdpi: 1280x1280 px
xxhdpi: 960x960 px
xhdpi: 640x640 px
hdpi: 480x480 px
mdpi: 320x320 px
ldpi: 240x240 px
GIMP tool is exactly what you need to create the images for different pixel resolution devices.
Follow these steps:
Open the existing image in GIMP tool.
Go to "Image" menu, and select "Scale Image..."
Use below pixel dimension that you need:
xxxhdpi: 1280x1920 px
xxhdpi: 960x1600 px
xhdpi: 640x960 px
hdpi: 480x800 px
mdpi: 320x480 px
ldpi: 240x320 px
Then "Export" the image from "File" menu.
My understanding is that if you use a View object (as supposed to eg. android:windowBackground) Android will automatically scale your image to the correct size. The problem is that too much scaling can result in artifacts (both during up and down scaling) and blurring. Due to various resolutions and aspects ratios on the market, it's impossible to create "perfect" fits for every screen, but you can do your best to make sure only a little bit of scaling has to be done, and thus mitigate the unwanted side effects. So what I would do is:
Keep to the 3:4:6:8:12:16 scaling ratio between the six generalized densities (ldpi, mdpi, hdpi, etc).
You should not include xxxhdpi elements for your UI elements, this resolution is meant for upscaling launcher icons only (so mipmap folder only) ... You should not use the xxxhdpi qualifier for UI elements other than the launcher icon. ... although eg. on the Samsung edge 7 calling getDisplayMetrics().density returns 4 (xxxhdpi), so perhaps this info is outdated.
Then look at the new phone models on the market, and find the representative ones. Assumming the new google pixel is a good representation of an android phone: It has a 1080 x 1920 resolution at 441 dpi, and a screen size of 4.4 x 2.5 inches. Then from the the android developer docs:
ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi
xxxhdpi (extra-extra-extra-high) ~640dpi
This corresponds to an xxhdpi screen. From here I could scale these 1080 x 1920 down by the (3:4:6:8:12) ratios above.
I could also acknowledge that downsampling is generally an easy way to scale and thus I might want slightly oversized bitmaps bundled in my apk (Note: higher memory consumption). Once more assuming that the width and height of the pixel screen is represetative, I would scale up the 1080x1920 by a factor of 480/441, leaving my maximum resolution background image at approx. 1200x2100, which should then be scaled by the 3:4:6:8:12.
Remember, you only need to provide density-specific drawables for bitmap files (.png, .jpg, or .gif) and Nine-Patch files (.9.png). If you use XML files to define drawable resources (eg. shapes), just put one copy in the default drawable directory.
If you ever have to accomodate really large or odd aspect ratios, create specific folders for these as well, using the flags for this, eg. sw, long, large, etc.
And no need to draw the background twice. Therefore set a style with <item name="android:windowBackground">#null</item>