的ImageButton拉伸背景图片 [英] ImageButton Stretching Background Image

查看:254
本文介绍了的ImageButton拉伸背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个没有边界的ImageButton的,但我正在与图像按钮的大小的问题。

I am trying to create an ImageButton with no border but I am running into an issue with the sizing of the image button.

使用Eclipse ADT我拖动的ImageButton的布局,并选择我的背景图片。出现图像按钮如下:

Using Eclipse ADT I drag an ImageButton to the layout and select my background image. The image button appears as follows:

正如你可以看到有背景图像和图像按钮周围,我想摆脱的边界。要做到这一点,我设置填充属性0dp。图像按钮现在看起来是这样的:

As you can see there is a border between the background image and the image button perimeter which I would like to get rid of. To do so, I set the padding property to 0dp. The image button now looks like this:

最后,我秤的类型设置为fitXY:

Finally, I set the scale type to fitXY:

请注意,该图像是<青霉>拉伸的和不再是原始图像的大小。 (我想要的ImageButton大小是完全相同的大小与背景图像相同。)

Notice that the image is stretched and is no longer the size of the original image. (I want the ImageButton size to be exactly the same size as the background image.)

下面是所有3张图片的快照彼此相邻赚取差价更清楚:

Here is a snapshot of all 3 images next to each other to make the difference more clear:

我曾尝试重新调整大小图像,设置最大大小的属性等,但没有从拉伸背景图像似乎prevent图像按钮。

I have tried re-sizing the image, setting the max size properties, etc. but nothing seems to prevent the image button from stretching the background image.

我如何prevent从的拉伸的喜欢它的形象呢?

How do I prevent the image from stretching like it is?

更新

我也尝试设置规模型到矩阵,但这里是发生了什么:

I also tried setting scale type to matrix but here is what happened:

推荐答案

只要设置你的形象为的android:背景的按钮,并设置 layout_height layout_width 的按钮 WRAP_CONTENT

Just set your image as android:background for button and set layout_height and layout_width for button to wrap_content

这篇关于的ImageButton拉伸背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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