这个 ImageButton 是可点击的。我需要在没有拉伸(stretch)的情况下在中心显示这个图标。有没有办法添加宽度和高度或属性?请给我一个主意。谢谢
<ImageButton
android:layout_width="60dp"
android:layout_height="wrap_content"
android:background="@drawable/usercalltab"/>
用户调用表.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<solid android:color="#ffdbab" />
</shape>
</item>
<item>
<bitmap android:src="@drawable/search"/>
</item>
</layer-list>
</item>
<item>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<bitmap android:src="@drawable/callme"/>
</item>
</layer-list>
</item>
</selector>
最佳答案
像这样尝试:
<ImageButton
android:layout_width="60dp"
android:layout_height="wrap_content"
android:src="@drawable/usercalltab"
android:scaleType="centerInside"
/>
或者android:scaleType="center"
我认为其中一个应该是您正在寻找的
关于android - 图像根据宽度和高度在图像按钮中拉伸(stretch),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15973486/