Android Appropriate Image Resolution for ImageView - android

What is the proper/right resolution for Image to be put using src in ImageView to avoid stretching or unscaled images?

if you are using a single color of background, u can use 9Patch images. but if you are asking about icons then you need different images for different resolutions in drawable folders like drawable-hdpi for hdpi devices drawable-xxhdpi for xxhdpi devices.
for more detailshttp://developer.android.com/training/basics/supporting-devices/screens.html

To understand the image size check out the following link image size (drawable-hdpi/ldpi/mdpi/xhdpi) . To avoid stretching use "android:scaleType="fitcenter/fitxy/centercrop"" for more detail check this http://developer.android.com/reference/android/widget/ImageView.ScaleType.html

Actually it totally depends on your placeholder or your needs, rather than single image you can make different sizes of image for different dp like small,large,normal,x-large .
probably https://romannurik.github.io/AndroidAssetStudio will save your time or new Android studio 2's built in plugin.
More resource
http://developer.android.com/training/basics/supporting-devices/screens.html

Related

Can we use images in one image density without any quality lost? (Android Image Density)

I work on an image sequence animation. I have 75 png files. I want to use images in one size without adding mdpi, hdpi, xhdpi etc types and get the same view on all devices. Is there a way to do this?
Best,
You Can try the following way may help you
(1)use only mipmap-xhdpi folder and create image according to mipmap-xhdpi density requireda and put all in xhdpi.
(2)Use Vector Drawable/Vector Graphic features in Android studio....Please read detail from https://developer.android.com/training/multiscreen/screendensities
(3)Please try to create the nine-patch image...Please read from https://developer.android.com/guide/topics/graphics/drawables#nine-patch.
https://developer.android.com/studio/write/draw9patch

Why is android studio degrading the quality of images?

When i add an image tothe drawable folder and then add a resource to the Image
View in android,the quality of the image gets highly detoriated..
This is the original image https://i.stack.imgur.com/CTq0U.png
This is the image in app
https://i.stack.imgur.com/zyx4n.jpg
That has to do with android screen resolutions. You can try viewing the same image on a device with a different resolution and you may find the image clearer or more detoriorated. The best way to curb this is using proper image resolutions for each android screensize. Create folders for all screen sizes in your drawables directory and get specified image sizes for each of the screens to optimize the resolutions. You will find a guidelines here

Android: Different image based upon screen size

Is there a way to have Android select a different image based upon the screen size? According to the docs and my testing, images must be placed in folders like drawable, drawable-mdpi, drawable-hdpi, etc.
These folders however relate to the screen dpi and not the screen size. The layout folders are used to handle different screen sizes but they don't allow you to store images in them. Only xml files.
So if I run my app on two devices with the same dpi but with different screen sizes, the same image gets selected from the same drawable folder. What I really want is for a larger image to be selected for the larger screen and a smaller image for a smaller screen.
Thanks for your help.
Yea, you are right, this is how works Android, by saving different pictures in particular folders (l,m,h and xh -dpi).
Where is your problem?
You want to keep images for all screen resolutions? Its too many of them.
Can you write more specific what you want achieve?
If you have a problem in layouts.xml, just check:
android:scaleType="..."
You can use 9-patch images. A 9-patch image can be stretched without loosing quality. You may refer to the following link for more information http://developer.android.com/guide/developing/tools/draw9patch.html

Setting background image in Android for mdpi, ldpi, hdpi

I'm working on setting background image sized 320X480 jpg, for >= android 2.2 versions.
As per my understanding from previous posts related to mdpi,ldpi,hdpi & info from http://developer.android.com/guide/practices/screens_support.html , we can use image sized to
ldpi, the recommended size is 240x320.
mdpi, the recommended size is 320x480.
hdpi, the recommended size is 480x800
My question is, will the above mentioned sized images (in jpg format) work (or) should i have to create a single image generated using 9 patch placed in drawable/
and also i'm little confused in using jpg format for background, as i have seen many sample programs referring to png format, is that a standard or can we use any format ?
Any help would be really appreciated.
Thanks - Jitendar
The screensize doesn't have to be the ones you mentioned - it can be any other. Therefore better use a ninepatch to stretch the image properly. You should still provide different versions of those though, especially if you have parts of the image that don't stretch.
You can use either jpg or png...it does not matter...As for backroung image you can use an image that will have all sizes...just put it in corect folders and you will not have any problems...

in which folder put image for setting to background of layout android

i am putting the image in three of the drawable,drawable-hdpi and drawable-ldpi for supporting all type of screen but when i see the output of background image in 240*320 screen resolution the background image is not as clear as origional so my question is where to, means in which folder i put the background image for supporting it all type of screen size and density, maens then my image should not distorted or bluer...
i am using the background image of size:320*480
thanks
make one folder name
drawable-nodpi
put your image in that and use it and dont keep that image in other folders.
the image will not be scaled or stretched.
Anoher Way
the best way is to make 3 different size images and put int drawable-ldpi(240X320),drawable-mdpi(320X480),drawable-hdpi(480X800) folder with the same name.
TO LEARN MORE PLEASE VISIT THIS LINK.
Supporting Multiple SCreens
You can put different same image in drawable-hdpi,mdpi and ldpi.Depending on the density of devices they will take the images from the corresponding folder.
With different devices you should have same image but with different size and density.for You can search in internet the specifications of devices.If density is less than 160 then put image in ldpi,if 160 then use mdpi and if 240 or above use hdpi.Also change the size of image to the screen size of corresponding device.Hope it will help.

Categories

Resources