安卓:按钮图像绘制可扩展用于其他屏幕尺寸? [英] Android: Button image drawable scalable for other screen sizes?

查看:169
本文介绍了安卓:按钮图像绘制可扩展用于其他屏幕尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮,我加载了绘制。图像比按钮的方式更大,所以我38像素(实际调整大小不是code或XML)调整图像以38。现在,当我加载图像,然后它看起来不错。我担心的是不同的屏幕尺寸,如果屏幕比较小,我的按钮变小,可绘制会越过其边界值吗?我怎样才能解决这个问题非常感谢

I have a button that I am loading a drawable for. The image was way bigger than the button so I resized the image to 38 by 38 pixels (actual resize not code or xml). Now, when I load the image then it looks good. I am worried about different screen sizes, if the screen is smaller and my button becomes smaller, the drawable will cross its boundries right? How can I fix it thanks a lot

PS:我读了Android最佳实践页面,但我不知道是否有比大小不同的3种不同的文件夹复制相同的图像以外的方法

PS: I read the android best practices page but I was wondering if there is a method other than replicating the same image in 3 different folders with different sizes

推荐答案

我猜你已经从阅读的最佳实践知道这一点,但也许你可以使用9片图像。它不适合所有的情况,但如果你有,你只是想延长的边缘图像,这是要走的路。

I guess you already know this from reading the best practices, but perhaps you could use a 9-patch image. It does not suit all situations, but if you have an image that you simply want to extend the edges of, it is the way to go.

如果您不能使用9补丁的具体类型的图像,试试你在模拟器几个不同屏幕尺寸的图像你担心它之前:)。我的经验是可绘制将默认扩展相当不错的。

If you can't use 9-patch for the specific type of image, try your image on a couple of different screen sizes in the emulator before you get worried about it :). My experience is that drawables will scale quite well by default.

这篇关于安卓:按钮图像绘制可扩展用于其他屏幕尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆