I got a new requirement to present an image instead of an error text if there is no items to show and the image almost have 440 KB (PNG) in size that given by my UI/UX designer. So I don't think it's fair to use it straightforward. As it's a transparent background image it's not possible to reduce the size by converting into JPG format. I got 4 resolutions of the image for placing it in different resolution resource folder. but if I keep all of them in my APK, that itself take near 1 MB, So I had taken only one image from drawable-xhdpi folder and kept in drawable-nodpi. Okay, So my queries as follows
1) How can I efficiently use that image ?
2) Any worries if I use JPG icons as substitute of PNG ?
3) What about keeping images like these only in drawable-nodpi and setting size in different dimension file ?
1) Convert the PNG to WebP if you only need to support API level 13+, otherwise use ZopfliPNG to optimize your PNG.
2) JPG does not support alpha channel and it's lossy.
3) Just put it in drawable-xhdpi and let Android scale the image for you. Only put images in drawable-nodpi if you don't want the image to be scaled.
Related
I made all the drawables for my android app, and it is in xxhdpi folder. How can I make sure that the app will downsize the drawables according to the resolution phone?
you can use this link
https://romannurik.github.io/AndroidAssetStudio/nine-patches.html for converting your image to the 9 patch images and down load it in .rar format. Extract it and paste into resource folder.by using 9 patch images are chooses according to the resolution of the device..
and if you want to take the icons you can use vector drawable . it will help to reduce your app size and best for all resolution devices.
for taking Vector Drawable
Right click on Drawable --> New --> Vector Assest .
If you do not want to scale the drawables manually and put in the right folder (e.g. -mdpi, -ldpi, ...), then the best solution could be use SVG format. Read more about this topic here.
Another benefit of using SVGs is that your app will use less space on the device.
I'm developing the splash screen for an Android application and I wanted to simply put an image designed in Photoshop as a background. The problem is that when I save the image its resolution is 1080 x 1920, but when I add it as a drawable in Android Studio, it gives me the error "Bitmap too large..." and says that the resolution is 3240 x 5760 (exactly 3 times bigger). I can't figure out why this happens, can you please help me?
Thanks
drawable folder in Android actually represents drawable-mdpi folder.
If you put images in drawable folder they will be upscaled in devices with higher dpi. That is why you are getting larger image.
Put your image in drawable-nodpi folder to prevent automatic up or down scaling of images.
you can also use this http://nsimage.brosteins.com/ link.
Go to Upload an image and a zip file will be downloaded containing 6 drawable files.
Extract files and copy those 6 folders in : \app\src\main\res.
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
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...
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.