Android button image size

I set the image as the background of the button. but I don’t know what image size should I create in Photoshop for all three drawable-hdpi, drawable-ldpi and drawable-mdpi folders?

Thanks.

+6
source share
3 answers

If your buttom image is a colored background, and if it can be a stretchable image, then create a bitmap using 9-Patch .

Otherwise, read the Alternate Drawables section on the Android developer site:

To create alternate bitmap drawings for different densities, you must match a scaling factor of 3: 4: 6: 8 between the four generalized densities. For example, if you have a bitmap, then it is 48x48 pixels for a medium-density screen (the size of the launch icon), all different sizes should be:

36x36 for low density

48x48 for medium density

72x72 for high density

96x96 ultra-high density

+11
source

I think this can help you, this is a conversion tool that adds image size (mdpi), it gives me the result in pixels for each screen size.

http://labs.rampinteractive.co.uk/android_dp_px_calculator/

Hope this helps!

+3
source

The extra tip for creating your life is a little easier in creating images for Photoshop. Create your image in mdpi, i.e. At 160 dpi. This is because Android calculates pixels as such.

 px = dp * (dpi / 160). 

So, if you want to make the button image 48x48 in size, create an image with that size and set the dpi to 160. Once you are done, just change the dpi to 120, 240 and 320 and save your images.

You don’t have to spend time figuring out what image sizes should be for different densities.

+2
source

Source: https://habr.com/ru/post/910670/


All Articles