Button Image size in android

2020-02-05 04:42发布

I have put image as background of button. but I don't know at what size of images should I create in Photoshop for all three folders drawable-hdpi,drawable-ldpi, and drawable-mdpi?

Thank you.

标签: android
3条回答
够拽才男人
2楼-- · 2020-02-05 05:22

If your buttom image is Plain-colored background and if it can be a Stretchable image then Create a bitmap using 9-Patch Tool.

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

To create alternative bitmap drawables for different densities, you should follow the 3:4:6:8 scaling ratio between the four generalized densities. For example, if you have a bitmap drawable that's 48x48 pixels for medium-density screen (the size for a launcher icon), all the different sizes should be:

36x36 for low-density

48x48 for medium-density

72x72 for high-density

96x96 for extra high-density

查看更多
Deceive 欺骗
3楼-- · 2020-02-05 05:25

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

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

Hope it helps!

查看更多
劫难
4楼-- · 2020-02-05 05:31

An additional tip for making your life a little simpler in creating images for photoshop. Create your image in mdpi, ie at 160 dpi. This is so because Android calculates pixels as such

px = dp * (dpi / 160).

So basically if u wanna make a button image of the size 48x48, 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 will not have to waste time calculating what the image sizes should be for different densities.

查看更多
登录 后发表回答