Is there a way to create xxhdpi, xhdpi, hdpi, mdpi and ldpi drawables from a large scale image?
I was using "Android Asset Studio". Now I am using IconKitchen, the successor to the Android Asset Studio, and a great new way to make highly customizable app icons for Android, iOS, web, Windows, Linux and Mac.
android resizing images for all screens (ldpi,mdpi,hdpi,xhdpi) and put in folders
Right click on your drawable folder
New > Image Asset for Launcher Icons, Action Bar and Tab Icons and Notification Icons
New > Vector Asset for Material icons, SVD's and PSD's
There is also a tool called Android Asset Studio which can do even more things for you
scale images for ldpi mdpi hdpi and xhdpi
Actually, you should not to place THE SAME images to all folders -ldpi, -mdpi, -hdpi.
Lets imagine, you want to support xxhdpi devices. You create image for xxhdpi (for example 1Mb) and put it to all folders.
And what will you get on a ldpi device? Image will be scaled. Quality of image on the screen will be horrible.
And another thing: if you want to have 100 images on a screen at the same time, each by 2-5Mb, and you create all of this images for xxhdpi devices, then you can get OutOfMemoryError on ldpi device.
So, the best practice is NOT to put the same images to all the folders.
If you have some resolution independent images, then you can put them into drawable folder (without postfix). But you should NOT put the same images to ldpi and xxhdpi folders.
So answers with resizing are terrible.
Look at this article
At "Alternative drawables" paragraph.
On this image
you can see that for xhdpi device you should have image 2 times larger than for mdpi.
And so on.
Hope it helps
Sizes for drawable: LDPI, MDPI, HDPI, XHDPI, XXHDPI, XXXHDPI?
Inside Android Studio, if you right click on the res folder, you can select New > Image Asset which will create properly sized drawables for those dpi bucket folders.
Optionally, you can also use a website like this one: http://romannurik.github.io/AndroidAssetStudio/index.html
You can also programmatically change width/height, but this is heavily discouraged due to how disgusting a smaller image looks when it's stretched large. Only use this programmatic solution if you use vector images.
How to use the different densities (mdpi, hdpi, xhdpi, ...)
If you want to create a background picture, your reference size is mdpi with 320x480px. You can then calculate the size according to the factor
- hdpi: 1.5 (480x720)
- xhdpi: 2.0 (640x960)
- xxhdpi: 3.0 (960x1440)
- xxxhdpi: 4.0 (1280x1920)
Note however, that nowadays devices have all kinds of other aspect ratios (mostly longer). So you have to design your background in a way, that the outer area does not contain important content. Then use ScaleType CENTER_CROP and your image should not be distorted (https://developer.android.com/reference/android/widget/ImageView.ScaleType)
Related Topics
How to Use an Arrayadapter in Android of Custom Objects
Android Viewmodel Additional Arguments
Fragments in Android 2.2.1, 2.3, 2.0. Is This Possible
How to Move the Layout Up When the Soft Keyboard Is Shown Android
How to Get Name of Wifi-Network Out of Android Using Android API
Android Get Screenshot of All Listview Items
How to Synchronise Projects to Github with Android Studio
How to Check Edittext's Text Is Email Address or Not
Encode and Decode Bitmap Object in Base64 String in Android
Android Sdk 22 - Searchview Rendering Problems
How to Display Input Errors in Popup
Hiding the Actionbar on Recyclerview/Listview Onscroll
The Import Android.Support.V7 Cannot Be Resolved
How to Send Broadcast from One App to Another App
The Import Com.Google.Android.Gms Cannot Be Resolved
How to Store an Integer Array in Sharedpreferences
Android: Background Image Size (In Pixel) Which Support All Devices