I have a quick question: will it work when I put the same 57px x 57px icon to all drawable-ldpi, drawable-mdpi and drawable-hdpi folders. Will it run on all devices?
in other words if small icon will be visible on big screens or x-large screens.
It will work, but you really should not use size of 57x57 for any screen size - scaled down images will look as ugly as scaled up. Better avoid it.
Please read more here: http://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html (yes, it is an official documentation).
Yes, it'll work. But it is good to have all icons. Because it'll be pixelat on large screens.
If you simple put icon in drawalbe folder (which is default folder) and you don't have any other folders like hdpi, mdpi, ldpi for all screen sizes. then it'll also be considered for all resolutions/sizes.
It will work. But it will not look well on some screen.
Related
If you put drawables in /drawables directory they will be scaled and if you want specific drawables for different densities you need to put them in specific directory (/drawables-hdpi, /drawables-mdpi etc.)
But if I have drawables only in /drawable-tvdpi will they scale down/up automaticly for ither densities?
Yes they'll scale, so if you put a 133 x 133px drawable in the tvdpi folder, it'll be 100px on mdpi, 150px for hdpi, and so on.
There's more information on the Android Developers - Screen Support page, but in general you can get away with just putting drawables in the tvdpi folder.
I believe they will, Android always picks the best available image inside your directories, i.e. if you have an mdpi phone, and two resource types, hdpi and xhdpi, it will try to pick the one immediately above the requested density (hdpi) instead of the bigger one, because it correctly assumes it' going to be enough. Take a look here.
However why not try it for yourself using Bluestacks? It's an Android simulator that runs pretty well. It's still in beta, but has served me well.
Last two questions stayed unanswered, I hope "third one's the charm" works :)
I want application that is HDPI use those drawables in folder "drawable-xhdpi" and LDPI devices those in "drawable-mdpi". So I don't have to duplicate same images. Is this possible?
Yes, Android scales drawables, selecting the drawable that will produce the best result. But not all scaling combinations work that well. Downscaling to MDPI can produce noticeably poor results. XHDPI to HDPI generally produces pretty good results. But given that the overwhelming majority of devices these days are HDPI, it's probably worthwhile to have HDPI resources. HDPI to XHDPI scaling is not terrible. Some 1280x720 devices uses XHDPI resource. These generally look ok. Google TV uses XHDPI as well. On a huge screen, scaling errors are visible.
LDPI devices are -- for all practical purposes -- non-existent now.
True that generating scaled resources is an enormous PITA. But, in my opinion, you really need to do MDPI and HDPI. And once you've got that unpleasant workflow down, it doesn't require a lot of extra work to generate XHDPI. For what it's worth, if your artwork is in vector format, the vast majority of resources don't need tweaking for specific resolutions. There doesn't seem to be any compelling need to pixel-align edges of square objects, for example. Usually it's only interior features in complex icons and artwork that benefit from some amount of pixel-pushing.
It's pretty clear that XHDPI is going to be come more and more common. Trust me, you don't want to go back and re-do all your artwork in XHDPI after the fact. My advice: if you intend to still be shipping your app a year from now, suck it up, and do the nasty as you go, while it's still relatively easy.
In my experience, if you place an image in just some of the drawable folders, but not all, the OS will choose the "best" image for the device that you are using, even if it is not exactly the perfect fit. For example, if you put an image called arrow.png ONLY in the drawable-hdpi folder, all devices will use that image for the arrow drawable, and scale it down or up appropriately, stretching or shrinking the image.
That being said, you should be able to accomplish what you want by simply putting your image in the right folders and allowing the devices to choose the correct one. For example, if you were trying to accomplish your task with only one image, arrow.png:
drawable-xhdpi/ -> arrow.png
drawable-hdpi/ -> empty
drawable-mdpi/ -> arrow.png
drawable-ldpi/ -> empty
drawable/ -> empty
If you use the app on an ldpi device, the device will use the mdpi image, as you wanted, because it is closest to the correct resolution. On the hdpi phone, it will use the xhdpi image, because it is again the closest to the correct resolution.
Yes. Android automatically downscales/upscales resources that it cannot find. If you were to only put resources in the XHDPI folder it would just work, Android would take care of resizing them to work in all the other densities.
We should add this code in MainActivity class and copy image to dhpi folder with ic_launcher, ic_launcher2, ic_launcher3 and ic_1 is image name, we can change size: width and height
int array_image[]={R.drawable.ic_launcher,
R.drawable.ic_launcher2,
R.drawable.ic_launcher3,
R.drawable.ic_1
}
I need every picture that I have in my program to be created for different densities (mdpi, ldpi, hdpi)? If yes, which density has to be for hdpi? Which one for ldpi?
And the second question. What I don`t understand, that what about screen sizes? What people usually do for support of tablets? They do not do anything with images, they just creating different layouts (which is more convenient)? Am I right or I do not understand?
It would be good to read something besides official documentation. Something that was written in language which is more human.
Thank you.
You can use 9-patch for some of you img. for example - backgrounds.
but actually - yes, you need images in 4-size
Proportion are:
mdpi= *4;
ldpi= *3;
hdpi= *6;
xhdpi= *8.
So if you have image mdpi 24*24 px, you must make it 36*36 px for hdpi
And some good resourse http://www.androidguys.com/2010/02/18/handling-multiple-screen-sizes-part-2/
commonly using just hdip images.(or xhdip)
but if u need correct size, make images for other densities
for tablets, need high resolution images.
I have a game which displays a full screen image in the background. At the moment I have one image size (1280x800). This works well on large resolutions but on smaller screens the shrinking somewhat degrades the image. You can see jagged edges and it is noticeably worse than what you could achieve using photoshop software.
I have different image sizes, but I am unsure how to utilize them. I know there are different dpi folders, but you can have resolutions of 480x320 and 1280x768 with the same dpi so I don't think these can be of use here.
I believe you can have different layout files for different screen sizes, but the image is not drawn using xml (and in fact would not be possible for my game).
I can only think that I must create a different file name for each size. Then when choosing which image to use I could take the screen dimensions and select the correct one? I am struggling to see how I can make an image look good on both 240x320 and 1280x800 resolutions.
All of the resource qualifiers in the framework can be applied to drawables, not just the dpi designators. In other words, you could create folders like this to segment your images as well:
drawable-ldpi
drawable-xlarge
drawable-normal
drawable-sw480dp
drawable-sw720dp
Even examples like these work...
drawable-v10
drawable-land
And so on...
You can create as many or as few different qualified directories for your image assets as you think necessary to preserve the quality. The Supporting Multiple Screens article in the SDK docs helps describe most of the qualifiers that best fit scaling image assets.
HTH!
I've created a menu icon and included a 36x36, 48x48 and 72x72 in the ldpi, mdpi and hdpi drawable folders. It looks fine on all devices except honeycomb tablets, where it seems like the padding around the Android icons are bigger than on my custom icon. I've included a screenshot (see how much bigger my 'Resume Reading' icon is than the android 'Back' and 'My Library' icons are). How do I make my icon look like this?
I think I found the problem. When using the Android resource icon's on a tablet, I think it changes the padding in order for the icon to be used in the action bar. So when displaying them in a pop up menu at the bottom they are appearing much smaller than they should be. The solution is to copy the android resources into our own resource folder as it says to do here http://developer.android.com/guide/practices/ui_guidelines/icon_design_menu.html
Most of your Tablets are not hdpi, they are xhdpi. While the Icon Design Guidelines are useful, they don't give the whole story. Consider reading Supporting Multiple Screens. Here, they tell you further ratios and dimensions. To save you some time, resources should be 3ldpi:4mdpi:6hdpi:8xhdpi meaning that your xhdpi icon should be 96 x 96. Please, read the whole document, though. It is insanely useful.