Making the drawables work according to resolution - android

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.

Related

What is to be the resolution of button for all drawable folder in android?

Button which i created for my app is of resolution 166*169. But it doesn't look perfect on my app when placed directly from drawable folder. So i created other drawable folders, but what is to be the resolution among them doesn't know. I do google that but nothing find which is relevant to me.
You need to create different png files for different drawables such as hdpi or mdpi. I recommend you do use 9-patch images. It is simple now that you can use a 9-patch generator, just put your image it will generate 9-patch images for all your drawable folders and you just need to import them.
Use SVG instead of PNG or JPEG in drawable, android support svg and this Link will help you

What is correct asset type for buttons in Android?

I would like to have simple geometry buttons in my application, like play, stop, record buttons on videocamera.
Unfortunately, I don't know how to prepare good asset for them.
If choose Image Asset to place differen resolutions in differen folder, I am confused by Asset Studio available options:
Here is a strange list of icon types, but no one says "button" icons.
Also, I am not sure, what size to choose for mid-resolution in pixels.
Next, if I choose Vector Asset I face with limited support of SVG in this program. At least, it doesn't understand SVGs created with Adobe Illustrator.
So, what is the best choice?
UPDATE
I drew blue shape in Adobe Illustrator and expoted it to SVG. The result is following:
I.e. color is lost and error message
In share.svg:
ERROR# line 1 <defs> is not supported
displayed.
Those options are for creating launcher, notification and actiobar icons but for a button u need to have a image and convert it manually into various resolutions and place it in the respective folders or else online converters are available to do that job for u.
As written here https://developer.android.com/guide/practices/screens_support.html
mdpi (medium) ~160dpi
that is, drawable-mdpi
About SVG:
You can easily implement data of SVG file using vector drawable.
you just can use drawable folder for vector graphic. Just put here some any vector file and use it as a background source.
https://romannurik.github.io/AndroidAssetStudio/ for example, here you can craete your own image set.

Android: Adding only two sets of drawables

Is there any way to use only two sets of drawables, one for xxxhdpi and xxhdpi and the other one for xhdpi/hdpi/mdpi/ldpi without having to create 6 drawable-{dpi} folders and duplicating the files.
You can.
Use SVG Images instead of PNG or normal extension pictures.
Then use the following link to convert the SVG to Vector.
Use vector as your drawable, your drawable (single) will support multiple devices.
Cheers!
Vector drawables are the stuff you mean. The limitation is that it is mostly used for drawing simple shapes.
You can sue it like this. Make a vector drawable for xxhdpi and it'll be used for all resolution sizes with suitable sizes automatically. This technique is currently being used to decrease apk sizes reasonably.

Optimizing icon usage?

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.

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...

Categories

Resources