android studio 3.6
In android app I use one image with different dimensions. I put image in the next folders:
drawable-hdpi, drawable-mdpi, drawable-xhdpi, drawable-xxhdpi, drawable-xxxhdpi
Nice. It's work fine.
Now what about flutter app. Is I also need to create different folders for every image's dimension?
P.S. I need this image for android and iOS version
As mentioned in the Declaring resolution-aware image assets. You can create folders based on the resolution and add images to it.
The main asset is assumed to correspond to a resolution of 1.0. For
example, consider the following asset layout for an image named
my_icon.png:
.../my_icon.png
.../2.0x/my_icon.png
.../3.0x/my_icon.png
On devices with a device pixel ratio of 1.8, the asset
.../2.0x/my_icon.png would be chosen. For a device pixel ratio of 2.7,
the asset .../3.0x/my_icon.png would be chosen.
Reference Assets and Images
For an Android App created using Flutter, You can still use these folders as shown below for varying screen densities
Related
So I was pasting some image in the drawable folder and I found that there are 2 folders as you can see in below picture
one is drawable and another is drawable-v24
So my questions are
why there are 2 drawable folders ?
whats the diff. ?
Do we really need them ?
any additional information is deeply appreciated . :)
The drawable folder is the default folder. The drawable-v24 applies to only those devices with Android v24 or higher- any file in that directory will be used instead of the file with the same name in drawable on the applicable versions. Do you need them both? Only if you want different images on newer devices, or if there's some feature of v24 and higher that you want to take advantage of where available. If not you can safely delete it.
There are many drawable folder types based on many factors,
Android OS version, ex: drawable-V21, drawable-V22, drawable-v23...etc
Density pixels - Refer https://developer.android.com/training/multiscreen/screendensities
This different folder types are used to access the images for particular needs, say if you have to load a small size icon in Lollipop OS and a different size icon in all other OS, you have to use drawable-V21 for lollipop and normal drawable folder for all others.
Another case based on the resolution of mobile phones, quality will vary on images, example: drawable-hdpi images supports Full HD mobiles, whereas drawable-xxhdpi support QuadHD mobiles and so on..
Switched my eclipse project to Android studio. I was maintaining resources under drawable-mdpi folder only. Now in studio the preview of XML loads images correctly. However when I run the app in a device with resolution higher than mdpi the app crashes, shows error inflating binary XML.
After a long analysis I found the issue that the device was trying to load images from its corresponding density folder which is not available. So I created the folder drawable-xhdpi and put images in that folder. Now the app works fine.
Why android studio can't pick image from other density drawable folder and resize which is possible by eclipse. I can't maintain 5 different drawable folders because there are lots of images.
you have to add "drawable-hdpi" resource directory and paste all the hdpi resources there because currently 70% android devices supports hdpi resolution images.
if you only maintain the hdpi, then it is also ok.
android manages all remaining resouces from hdpi resouce directory.
Android application resource directories provide different layout designs for different screen sizes and different drawables. These different drawables are used by android to support a major range of all the android devices present out there. It's a standard practice to put your resources considering these densities. Coming back to your query:
Why android studio can't pick image from other density drawable folder and resize which is possible by eclipse. I can't maintain 5 different drawable folders because there are lots of images.
For your case,In order to maintain this you could create a drawable with nodpi and put your all resources there. nodpi focus resources for all densities.Your resources should be density-independent resources. The system does not scale resources tagged with this qualifier, regardless of the current screen's density.
Hope this will clear your doubts, for more insight you can also look this.
you don't need to add all images to each difference size folder but depending the size of the image you might need to add images to different folders.
simple example is this can occour once you add high res/size images in normal drawble folder
Skipped 100 frames! The application may be doing too much work on its main thread.
This might not crash your app but will make it's performance down.
and
Different density folders were added later on for Android which means that...
If you wanted to be lazy and just add one asset the best choice would probably be the HDPI asset if your min app target < 8 and XHDPI if its >= 8. This is because the system will scale the resource up and down, but you would still want to start off with the highest resolution possible.
If you want to have complete control over how the assets are scaled then you can by all means provide your own for all / some of the densitys. In practise I generally provide HDPI / XHDPI as above and give all the resource buckets for things like logos / AB icons / App icons etc. I generally find the auto scaling to be pretty good and work for most situations, but will occasionally have to supply and extra LD/MD asset if its a small asset / contains small text etc. Plus if i duplicated all assets for things like XXXHDPI I would get pretty good apk bloat.
You can also use IDEs built in tools to add a single asset for many densitys at once. In Android Studio 0.6 this is File->New->Image Asset and a wizard will appear.
I have never noticed or heard of any perfomance impact of allowing Android to scale assets automatically - presumably this is done in hardware.
It may not look great when auto scaling down to LDPI say so you can optionally provide your own scaled assets for all other densities.
taken from : https://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources
Do we need to add all images with different dpi to Android Apps
I want to make all drawables files from one image.png
I tried Image asset from android studio but it creates too small images..
Anyone got an idea how can i generate from one png file all drawables files?
Not sure if this is what you're looking for. But with this tool you can generate images of multiple sizes:
Android Assets Studio
You can upload images, and get icons back, in the sizes of xxxhdpi, xxhdpi, xhdpi, hdpi, mdpi
I am new to android and this concept of multiple resources is killing me and its Halloween =)
Ok so for Normal screen we have following HDPI per http://developer.android.com/guide/practices/screens_support.html#range
WVGA800 (480x800)
WVGA854 (480x854)
600x1024
so my image will go in drawable-hdpi. should image be 480x800, 480x854, 600x1024, or all 3 in the drawable-hdpi?
If all 3 are doing to be in drawable-hdpi, how I will name them? They can't have same names.
Thank you in advance
The common drawable folders are drawable-hdpi,drawable-mdpi,drawable-ldpi.
These folders are used to tell android which set of image to use on different situations.
The different names that can be used are given here.
When a small ldpi phone is being used and it tries to refer an image named icon.png. It first refers the drawable-ldpi folder. If it doesn't find it there, it moves to the other folders till it finds the image. But if the phone was an hdpi device, android would first look into the drawable-hdpi folder. So if icon should be of different sizes, you put the different sized image in each folder with the same name. And android will decide which folder to access the image in run time.
This might be a bit confusing in the beginning but you will get used to it after a while.
I want to deploy my application on different screen sizes using the 1.6 feature.
I exported the drawable resources with different resolutions in drawable-ldpi, drawable-mdpi and drawable-hdpi folders.
On android 1.6 and 2.0 everything looks good.
My problem is that on 1.5 the drawable-ldpi resources are used instead of drawable or drawable-mdpi ... the application still works but it renders the images scaled and the image quality is lost.
How can I configure the application so that on 1.5 the only the drawable-mdi folder will be used?
I'd like to keep the apilevel to 3 so that the same apk will run on 1.5, 1.6 and 2.0.
Try adding -v4 to your -ldpi, -mdpi, and -hdpi directory names, and having a base res/drawable/ for use by Android 1.5.