About Android Image and Asset Sizes

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:

  1. In the Project window, select the Android view.
  2. Right-click the res folder and select New > Image Asset.

Sample Image


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

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

Configure Image Asset

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



Leave a reply



Submit