调整的ImageButton?ImageButton

2023-09-07 03:21:30 作者:写给年华的无效信

我有一个ImageButton的,我使用了包括@android:绘制/ ic_menu_more图像。但它太大。什么是调整它们,让它们适合我的形式更好的最好方式?另外,可以在XML中旋转? (只有一次,而不是基于状态)

I have an ImageButton, I'm using the included @android:drawable/ic_menu_more image. But it's too large. What's the best way to resize that so it fits into my form better? Also, can it be rotated within the xml? (just once, not based on state)

推荐答案

尝试设置安卓背景而不是机器人:SRC 用于设定图像上的按钮。这可能会在你的情况有所帮助,因为这将图像伸展到你的按钮的大小。此外,您必须指定固定尺寸的按钮(使用,而不是的PX )。例如:

try setting android:background instead of android:src for setting the image on the button. That might help in your case, since it will stretch the image to your button's size. Also, you will have to specify fixed dimensions for the buttons (use dip instead of px). Example:

<ImageButton
     android:background="@drawable/ic_menu_more"
     android:layout_width="50dip"
     android:layout_height="50dip" />