Localized drawable folder not always works - android

Localized drawable folders works like this that phone searchs for a images in specific folder (in example drawable-sw720p) and if there is nothing it needs right now it searchs in normal drawable folder, right?
I have few images dedicated to tables. So, I need 4 drawable folders (sw600dp, sw720dp, xxhdpi, xhdpi also). And it should works fine, but - in these 4 folders I have the same image (multiplied by amount of different images), so in the end my app is a little bit too heavy.
Now my problem: some time ago I tested my other app on my friend's phone and I realized that his phone doesn't take images from drawable folder (it only takes images from it's folder like drawable-mdpi). So, I had to put all the images into drawable-mdpi and to others drawables event if some images are exactly the same.
So, now I want to minimalize my app size by putting all same events into the standard drawable folder and to localized folders only the ones which are different - but I'm scared of the situation I wrote about.
Is there any way to solve this problem? Or no and I just should copy the same images into every drawable folder I have?
Please let me know, I'm sure someone here knows the best practise to make it lighter and works just fine on all the phones (including dumb ones like my friend's) ;)

Related

Android Studio - New project uses over 20MB of memory

If I create a blank new project and run it, it uses 23MB of memory.
If I add one 540x960 png image to the background of the layout, it uses 47MB of memory.
If I add an image button with a background image on it, it uses 64MB of memory.
This continues to go on if I add things, and this is way too much. On the app I am currently working on, I have memory used at between 180-210MB of memory. I figured there was something wrong I was doing with loading the images, so I ended up putting them all on imgur, and loading them in with Glide. This reduced the memory by a small amount, and also doesn't explain why a new blank project would use 23MB.
I thought there might be some kind of setting, but I re-installed with default settings and am still getting the problem.
I experienced a similar issue when I put the drawable in the wrong resolution folder, especially the standard "drawable" folder is a pitfall since it is assumed to contain the image in "mdpi" resolution, so the image gets upscaled like crazy on xxhdpi devices.
Here's a simple test to figure it out, move the images into a folder called "drawable-nodpi" and check for the memory consumption.
Then make sure to provide the image in the right resolution in their dedicated folders, and avoid the "drawable" folder for images, just use it for xml drawables.
What basically happens is if you put your "540x960" image in to the standard drawable folder, it is assumed to be mdpi, if you view it on a relatively modern "xxhdpi" devices the image gets upscaled by a factor of 3 e.g it will be "1620x2880" and therefore consume much more memory.
http://developer.android.com/guide/practices/screens_support.html

How to support multiple devices with many pictures in application?

I saw many questions like these and read many docs, but I'm still not sure what is the proper way. I have application with 500 photos, and first how I was doing it was to scale every photo 5 times, to the pixel sizes for each ldpi, mdpi, hdpi, xhdpi and xxhdpi. But, after doing this, application got much bigger than it should have and since you can only upload .apk with 50MB to market, I found myself in trap.
I found several options which can be made here, but not sure which is the proper one:
Make a multiple layouts for each of this densities on devices and scale with different dp's in them
Make multiple .apk files, each for every device with different densities (still, Google is making accent on this option to make it only if you really can't make it anyhow else - why is that? this would be perfect for me, since I already have photos prepared for each density)
Make multiple pictures and put it just in one .apk - this can't work for me, since the .apk is too big
Make pictures which are good for MDPI device, put them in "drawable" and they will automatically resize bigger for other devices and smaller for smaller density devices - this makes problem since pictures, when they're being resized from MDPI to other bigger dpi devices, pictures are blurry.
So, anyways, proper way of handling this would be to follow first option, am I right? I should just take xxhdpi pictures (so they're always scaled from the best picture), put them into drawable-nodpi? However, I have some problems with scaling on ImageButtons.
Please, tell me how to make it properly.
My practice is using only one apk to keep the app simple and easy to develop and publish.
Use only one drawable, the high the better. it depends the final apk size you(market) can bear.
May be this question will help:
Only use XHDPI drawables in Android app?
An addition to the Loki's answer. You could resolve the poor perfomance on small scale devices making a cache folder for images. Downsize the image the first time the device loads it, according to the density of the device, save it to the cache folder, and the next time use the cached image.
Bonus if you make this in an batch process in the background!
I don't know but could this be done as an update to the app. You download a plain vanilla app that prompts the user to upgrade, or just does it automatically.sounds like something Google needs to improve on. When I download an app I only need one app for one language one device.sounds like Microsoft mentality

Will adding images in all mdpi/ hdpi/ xhdpi etc increase the size of app for all devices ? - Android

I've read "Supporting Multiple Screens" on the official docs.
I have around 15 activities. I currently have 4 background images. I've randomly assigned a background image to each of the screens in simple XML.
All these images are around 400X800 in the drawable hdpi folder.
Now the problem:
My app looks bad on tablets. The low resolution images are stretched out.. making them very blurry. So, I'm thinking about adding some higher res images.
The question:
So, now I have 4 images in the hdpi folder. (read slowly) ... If I add the same images of higher resolution in the xhdpi folder .... Will a device with screen of hdpi resolution also have to save the other res pics ?
I know that was confusing, below I explain with an example:
Okay, so I have three devices..
One small,
One medium,
One Tablet.
Now I have 3 sets of images in the mdpi, hdpi and xxhdpi.... for each of these.
Now, will the small device's apk file also contain the bigger images which are not used in it? ... I mean, can android choose which images it wants to download (changing the app size for different devices) ...?
Or does it simply download everything (increasing the app size)... and choose later on while running ?
The thing is, my app is like 800kb .... and adding 3-4 background images for large phones or tablets will drive up the app size to 5-6 mb... That's what I don't want.
So, are all the things stuffed in the apk downloaded equally on all phone sizes ? or are the pics downloaded selectively?
Do small phones unnecessarily download the big images too ?(vice-versa for tablets ?)
(I asked this question, because in many android apps , their size says "Variable for different devices" or something like that... and there's no mention of this whatsover, anywhere on the internet. Trust me, I googled for an hour.)
Yes. Your project size will increases whatever images added in all folders. If you are designing for 4 different screen your apk size will increase automatically. If you want any images common for all screens, then you can create a drawable folder and place the image in it. So it will pick automatically. Both apk size and your project quality are important. So you should consider image size when adding to the project. By using padding and other xml factors you can adjust screen size by same image also.
The whole apk is downloaded together with all images for all resolutions. As you usually upload only one file to Google Play, the same file is downloaded by everyone.
There is an option do distribute different apk files based on device onfiguration but it is not very convenient to manage.
You can read about publishing multiple apk in here: http://developer.android.com/google/play/publishing/multiple-apks.html

drawable folder android

On my android project I have 5 kind ok drawable: xxhpdi, xhpid, hpdi, mpdi et lpdi
But I don't realy understand in witch file set my images
I had a look to this link: http://developer.android.com/guide/practices/screens_support.html
I need to class my pictures by size and by px/in
I have ic_launcher in my folders:
xxhpdi => 144*144px
xhpdi => 96*96px
hpdi => 72*72px
mpdi => 48*48px
lpdi => vide
But they are all in 72*72 px/in
I'd like to know how to set my pictures in res folders, why not just have a xxhpdi image ?
and did we always need to have 5 image, it weighed the application.
Thanks
Resolutions were explained in other answers. Regarding the question about weight of the app, You could provide different apks for different devices via Android Market, so particular apk would include only images for particular screen.
Moreover, the same time You don't need to do simultaneous development of many branches etc. just because of images differences, just follow Android documentation on support multiple screens and produce separate builds using aapt -c key which would allow You to have only necessary configuration included in every build..
The Android system will choose the closest 'density bucket' (drawable folder) to the current device, and use that for some final resizing to the devices exact size.
Its a guideline to provide an image for every density bucket to ensure the best result, but in practice often an image will look just fine by only adding it in 1 or 2 folders.
If you have a problem with having some big images that make your app huge, cause you have to add them 5 times, you could try around with adding those only in 1 or 2 folders.
Per example, xxhdpi is only nexus 10 at the moment, are you even really supporting that? ldpi is also not very common anymore. You could try adding it only in xhdpi, and scaling will probably look fine.
For the rest your images shouldn't be much more than some simple icons, which shouldn't take up a lot of space.
tl;dr: Yes if you want to follow guidelines for best result, but you can probably cut on app size without people actually noticing.
Android comes different screen resolutions, each resolution depends on screen width/height.For mobiles you place the corresponding sized images in res folder. During run time device itself find the resolution and re size the resolution it needs. For some cases you may get issues like image squeeze etc. At these time you place the corresponding image sizes with their corresponding res folder with same names.
I wrote a little toole for this.(BitmapCat) It scaled png-, bmp-, and jpg images for Android apps in:
ldpi(low-density)
mdpi(medium-density)
hdpi(high-density)
xhdpi(extra-high-density)
xxhdpi(extra-extra-high-density)
Here you can download it: http://blog.axxg.de/bitmapcat-en/

Is there a painless workflow for creating/saving/editing different android density drawables?

I am saving 4 copies of every image in my game, each with a different density. They are saved in the relevant res/drawable-* folder, and it seems to be working great on various devices.
So, currently, I open up photoshop, and have one psd for each image. I edit the vector's appropriately, change the density, and save the image in the appropriate folder. I have to do this 4 times, for every image. It takes forever, and I am trying to avoid getting sloppy and messing up one density of one image and not noticing it.
Is there a better way to this? When you have to create and edit your drawables over the course of development, how do you do this?
Check out batch processing in Photoshop. It will be the same thing you do, only automated
http://howto.wired.com/wiki/Batch_Process_Images_in_Photoshop

Categories

Resources