1

我正在尝试在我的图像按钮上设置前景图像。这样,按钮灰色背景是可见的,图像出现在前景中。

我会很感激任何想法,请。

谢谢

4

2 回答 2

4

如果要在设置前景图像时删除该灰色背景,请设置一个空的背景图像。或简单地而不是设置前景图像,仅将背景图像设置为按钮。我希望这能帮到您。

用代码编辑

<ImageButton android:text="Button" android:id="@+id/button1"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:src="@drawable/icon"/>

当您使用 android:src 属性使用仅设置前景时

<ImageButton android:text="Button" android:id="@+id/button1"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:background="@drawable/icon"/>

当您使用 android:background 属性仅设置背景时

于 2011-09-06T11:58:51.600 回答
-1

只使用按钮而不是图像按钮。在 xml 中使用 android:background="@drawable/yourdrawablewhichyouwanttoshow" 希望对您有所帮助!

于 2011-09-06T12:53:07.550 回答