我怎么能伸展的ImageButton图像到的ImageButton的整个区域?图像、区域、我怎么能、ImageButton

2023-09-04 11:28:17 作者:归去如风

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

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.