我正在尝试在xamarin android的.xaml文件中调整(缩小)imagebutton的大小,但是我在顶部和底部都被裁掉了imagbutton。有人可以建议我如何将图像缩小到所需的大小而又不对图像进行任何削减。
我正在使用Visual Studio 2015工具在Xamarin中构建android
下面是我的代码
<?xml version="1.0" encoding="utf-8"?>
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myButton"
android:layout_width="120dip"
android:layout_height="150dip"
android:layout_marginTop="50dip"
android:layout_marginLeft="50dip"
android:padding="100dip"
android:src="@drawable/geocursor_pressed" />
编辑答案:
these extra 3 things should be added
android:adjustViewBounds="true"
android:padding="10dp"
android:scaleType="fitCenter"
By changing padding you can get desired fit of image in button
Refer Link for more information :
您应该尝试使用scaleType
。
这个例子可能会很有帮助
解决方案应该是android:scaleType="fitXY"
。
编辑
由于问题已被编辑,并且它是ImageButton,因此解决方案是不同的scaleType和另一个选项。
android:scaleType="fitCenter"
android:adjustViewBounds="true"
另外填充可能太大。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句