简体   繁体   English

按钮Android中的图像大小

[英]Button Image size in android

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? 但我不知道我应该在Photoshop中为所有三个文件夹drawable-hdpi,drawable-ldpi和drawable-mdpi创建多大的图像尺寸?

Thank you. 谢谢。

If your buttom image is Plain-colored background and if it can be a Stretchable image then Create a bitmap using 9-Patch Tool. 如果您的buttom图像是纯色背景,如果它可以是可伸缩图像,则使用9-Patch Tool创建位图。

Otherwise, read about Alternate Drawables section on Android developer site: 否则,请阅读Android开发者网站上的Alternate Drawables部分:

To create alternative bitmap drawables for different densities, you should follow the 3:4:6:8 scaling ratio between the four generalized densities. 要为不同的密度创建替代位图可绘制,您应遵循四个广义密度之间的3:4:6:8缩放比例 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: 例如,如果你有一个位图可绘制的中等密度屏幕的48x48像素(启动器图标的大小),所有不同的大小应该是:

36x36 for low-density 低密度36x36

48x48 for medium-density 中等密度48x48

72x72 for high-density 72x72高密度

96x96 for extra high-density 96x96用于超高密度

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. 我认为这可以帮助你,是一个转换工具,添加图像大小(mdpi),它给出了每个屏幕尺寸的像素结果。

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

Hope it helps! 希望能帮助到你!

An additional tip for making your life a little simpler in creating images for photoshop. 另一个提示,让您的生活在为photoshop创建图像时更简单一些。 Create your image in mdpi, ie at 160 dpi. 以mdpi创建图像,即160 dpi。 This is so because Android calculates pixels as such 这是因为Android计算像素

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. 所以基本上如果你想制作尺寸为48x48的按钮图像,创建一个具有该尺寸的图像并将dpi设置为160.完成后,只需将dpi更改为120,240和320并保存图像。

You will not have to waste time calculating what the image sizes should be for different densities. 您不必浪费时间计算不同密度的图像尺寸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM