我怎么能伸展的ImageButton图像到的ImageButton的整个区域? [英] How can I stretch the image in imagebutton to the whole area of the imagebutton?

查看:136
本文介绍了我怎么能伸展的ImageButton图像到的ImageButton的整个区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是一张图片,这将有助于你理解我的问题:

Here is a picture that will help you understand my problem:

我想在的ImageButton 所示的图像回复到的ImageButton 的整个区域。 正如你可以见式数字1的画面只需要大约95%的的ImageButton ,你还可以看到的边界的ImageButton

I want to stretch the image shown inside ImageButton to the whole area of the ImageButton. As you can see- The picture with the number 1 only take about 95% of the ImageButton and you can also see the boundaries of the ImageButton.

我还是想maintaince图像按钮样式

下面是我如何使用ImageView的:

Here's how i am using ImageView :

        <ImageButton
            android:id="@+id/secondActivityBbuttonDownRight"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            android:scaleType="fitStart"
            android:src="@drawable/111" />

我想我发现了什么是我的问题。 我需要一个可以只包含一个图像,并有一个点击效果的自定义组件。

I think I found out what is my problem. I need a custom component that can contain only an image and have a clicking effect.

推荐答案

ImageButton的是ImageView的。照片 如果你想你的形象,以填补按钮
比集安卓scaleType =fitXY,因此Android您在设置图像:SRC 将被拉伸以填补整幅图像按钮。

ImageButton is ImageView.
If you want your image to fill button
than set android:scaleType="fitXY", so the image you set in android:src will be stretched to fill whole image button.

的ImageButton已根据您的图片和填充背景。
如果你不想背景
设置安卓背景=@机器人:彩色/透明
。 如果你不想填充
机器人:填充=0或设置背景没有填充

ImageButton has a background under your image and padding.
If you do not want background
set android:background="@android:color/transparent".
If you do not want padding
set android:padding="0" or set background without padding.

这篇关于我怎么能伸展的ImageButton图像到的ImageButton的整个区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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