Android的:如何设置的ImageButton的src图像的高度/宽度? [英] Android: how to set the height/width of the src image of a ImageButton?

查看:1018
本文介绍了Android的:如何设置的ImageButton的src图像的高度/宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

安卓?如何设置的ImageButton的高度/宽度的图像(源图像的背景这一翻译)的

Android: how to set the height/width of the image(src image intead of the background) of a ImageButton?

我想设置顶层图像(不是背景)图像的高度/宽度,图像的大小应该是定制,而不是自动fullfill按钮

I want to set the height/width of the top level image(not the background) image, the size of image should be customized instead of fullfill the button automatically

推荐答案

您可以只使用的ImageButton scaleType 属性C>。 将其设置为 fitXY fitCenter 或其他任何根据您的需要。

You can just Use the scaleType attribute of ImageButton. Set it to fitXY or fitCenter or anything else according to your need.

像这样

<ImageButton
    android:id="@+id/imageButton"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:scaleType="fitCenter"
    android:src="@drawable/some_image">
</ImageButton>

这篇关于Android的:如何设置的ImageButton的src图像的高度/宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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