【发布时间】:2013-01-26 05:28:49
【问题描述】:
我想在图形布局上使用鼠标或使用代码来调整 ImageButton 的大小
android:layout_width,android:layout_height。但每当我这样做时,ImageButton 不会调整大小,事实上它并没有更小,而是在边缘被切割。
提前致谢
【问题讨论】:
标签: android resize imagebutton
我想在图形布局上使用鼠标或使用代码来调整 ImageButton 的大小
android:layout_width,android:layout_height。但每当我这样做时,ImageButton 不会调整大小,事实上它并没有更小,而是在边缘被切割。
提前致谢
【问题讨论】:
标签: android resize 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"
/>
【讨论】:
这可能是您的图像大小的问题..尝试使用调整大小的图像然后在您的图像按钮中使用它。然后您可以设置按钮的宽度和高度。
【讨论】: