我想ImageButton
在图形布局上使用鼠标或通过
android:layout_width
,使用代码来调整我的大小android:layout_height
。但每当我这样做时ImageButton
,实际上并没有调整大小,它并没有更小,而是在边缘被切割。
提前致谢
我想ImageButton
在图形布局上使用鼠标或通过
android:layout_width
,使用代码来调整我的大小android:layout_height
。但每当我这样做时ImageButton
,实际上并没有调整大小,它并没有更小,而是在边缘被切割。
提前致谢
首先尝试使用android:background而不是android:src来设置按钮上的图像。在大多数情况下,它会有所帮助。如果没有,请查看这些..
<ImageButton
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@drawable/ic_star_border"
/>
or
<ImageButton
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?selectableItemBackgroundBorderless"
android:scaleType="fitXY"
android:src="@drawable/ic_delete" />
您必须为按钮指定固定尺寸(使用dp
而不是px
)。例子:
<ImageButton
android:background="@drawable/ic_menu_more"
android:layout_width="50dip"
android:layout_height="50dip"
/>
这可能是图像大小的问题。尝试使用调整大小的图像,然后在图像按钮中使用它。然后您可以设置按钮的宽度和高度。