About Android image and asset sizes
mdpi
is the reference density -- that is, 1 px on an mdpi
display is equal to 1 dip. The ratio for asset scaling is:
ldpi | mdpi | tvdpi | hdpi | xhdpi | xxhdpi | xxxhdpi
0.75 | 1 | 1.33 | 1.5 | 2 | 3 | 4
Although you don't really need to worry about tvdpi
unless you're developing specifically for Google TV or the original Nexus 7 -- but even Google recommends simply using hdpi
assets.
What this means is if you're doing a 48dip image and plan to support up to xxhdpi resolution
, you should start with a 144px image (192px if you want native assets for xxxhdpi) and make the following images for the densities:
ldpi | mdpi | tvdpi | hdpi | xhdpi | xxhdpi | xxxhdpi
36 x 36 | 48 x 48 | 64 x 64 | 72 x 72 | 96 x 96 | 144 x 144 | 192 x 192
And these should display at roughly the same size on any device, provided you've placed these in density-specific folders (e.g. drawable-xhdpi
, drawable-hdpi
, etc.)
For reference, the pixel densities for these are:
ldpi | mdpi | tvdpi | hdpi | xhdpi | xxhdpi | xxxhdpi
120 | 160 | 213 | 240 | 320 | 480 | 640
What's the right size for an Image Asset?
"512 x 512 pixel image [is] appropriate for the Google Play store"
To start Image Asset Studio, follow these steps:
- In the Project window, select the Android view.
- Right-click the res folder and select New > Image Asset.
Continue by following the steps to:
- If your app supports Android 8.0, create adaptive and legacy launcher icons.
- If your app supports versions no higher than Android 7.1, create a legacy launcher icon only.
- Create an action bar or tab icon.
- Create a notification icon.
for more detail
Why every image I add to my app is in small size?
You should add your Images to drawable folder of your Project. Image Asset tool is for adding images for icons (Action bar icons, Launcher Icon or Notification Icons), refer to this link to understand what is Asset Image tool. Also bare in mind that a good practise is to use many same images with different resolutions (mdpi - hdpi - xdpi - xxdpi - xxxdpi) in order to support different resolutions for android devices, you can refer to this link.
Android: Image from assets folder is smaller than it should be
When you place an image in drawable folder then the images are classified on density of screen while if you put images in assest folder then android need to calculate density.
If you want to use images from assest folder then this code will help you.
Options opts = new BitmapFactory.Options();
opts.inDensity = DisplayMetrics.DENSITY_HIGH;
drawable = Drawable.createFromResourceStream(context.getResources(), null, is, srcName, opts);
see here
Image loaded from assets folder comes in different size than res/drawable
Android: Accessing images from assets/drawable folders
Android Studio 3.2 Add Image Of Custom Size (not icon)
Limited modification is to comply with the material design specification. you could use vector asset if you want to get different size image.
and notice you should down image with SVG
format, read the ref in here
another way is using thrid party plugins like Android Drawable Importer, which is flexiable and simpler.
right picture resolution for image asset?
Go to Andorid Studio
File -> New -> Image Asset
Choose
Icon Type: Launcher Icons (Legacy Only)
enter your icon name as: ic_launcher
Asset Type: icon
Choose the Path of your Icon. (Choose icon with minimum size of 512x512)
There will be a slider to adjust the padding of the Launcher Icon. You can use it to adjust the image.
Add the background if you want. But you need to adjust the padding if you want to see this background color.
Choose your Scaling to crop.
Choose your shape: Square/Circle/Horizontal/Vertical/None
Effect: None
Now click the "Next" button.
it will take you to a confirmation page. Click the "Finish" button. The old icons will be replaced with new icons.
Done.
You can choose Icon Type: Launcher Icons(Adaptive and Legacy) if you want to create the best Launcher Icon. But as a beginner, I suggest you should start with Legacy Only ;D .
Hope this will help you.
Related Topics
What Is Exactly a "Clock Tick" in the Context of Android CPU Usage
Android: How to Periodically Send Location to a Server
How to Make a Gridlayout Fit Screen Size
Error: Fix the Version Conflict (Google-Services Plugin)
How to Keep/Exclude a Particular Package Path When Using Proguard
Android: How to Make a Clickable Map Image with Each Country Producing a Different Action
How to Find Android Source Code Online
Software Keyboard Resizes Background Image on Android
How to Prevent System Font-Size Changing Effects to Android Application
Share Sqlite Database Between 2 Android Apps
How to Change Endianness Mid-Execution on Arm (Android/Linux)
Android Command Line Tools Sdkmanager Always Shows: Warning: Could Not Create Settings
Android Gradle Could Not Reserve Enough Space for Object Heap
Blue Dot and Circle Is Not Shown on Mylocation Using Android Fused Location API
How to Prevent a Service from Being Killed by Os
Programmatically Check Play Store for App Updates