android - 如何对齐图像按钮中的图像

标签 android android-imageview

我想将我的图像放在分配的图像按钮 View 中。但它并没有固定在那个空间里,看起来很奇怪! !是否可以将图像与分配给图像按钮的空间对齐,或者我必须裁剪和设置?

最佳答案

ImageButton 标签中的图像要左对齐。

<ImageButton 
    android:id="@+id/sample"
    android:layout_gravity="left"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:scaleType="fitStart" 
    android:src="@drawable/sample" >
</ImageButton>

关于android - 如何对齐图像按钮中的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17120250/

相关文章:

android - 使用 GSON 解析 JSON 日期

android - 如何在 Android map v2 上获取中心位置?

android - 字节数组到位图图像android

android - 使用 Firebase 将推送通知发送到所有注册设备的 JSON 数据

java - 无法设法更改 Spinner 上的文本颜色

android - ShelfViewActivity 类型未定义方法 setContentView(int)

android - 在Android中以编程方式放大图片

android - 如何相对于屏幕尺寸缩放图像?

android - 在不移动叠加 View 的情况下裁剪和缩放图像,而不是在 ImageView 中移动图像

android - Drawable 文件夹中图像的正确大小