繁体   English   中英

如何调整图像大小按钮?

[英]How to resize Image to button?

所以我有一个ImageButton但图像非常适合它。 我试过android:scaleType="center"并且它失败了,因为图像居中但是它太小并且尝试了fitXY但结果相同。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#f1e8e8"
    tools:context="com.example.bassam.myapplication123.MainActivity">
    <ImageButton android:id="@+id/myButton"
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:padding="100dip"
        android:background="#ffffff"
        android:src="@drawable/Work"
        android:scaleType="fitXY"
        ></ImageButton>
</RelativeLayout>

如果我理解您的关注是正确的,您只需要将图像缩放到ImageButton本身的大小,只需使用

android:scaleType="fitCenter"

根据ImageButton的大小调整图像。 尝试一下,让我知道它是否有效。 干杯! :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM