Android - 如何去除图像按钮上的丑陋边框?

Android - How do I remove the ugly borders on imagebuttons?

http://i.imgur.com/WCGjcOe.png

非常直截了当的问题 - 如何删除那些灰色边框?

图片(.png 文件)只是星星、文字和周围的白色。然后,当我将它们添加为图像按钮时,它们会添加我真的不想要的丑陋的灰色边框。

<ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/starButton1"
        android:src="@drawable/star_pink_1"
        android:onClick="starButton1Clicked"
        android:layout_below="@+id/imageView"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

您必须将 xml 属性背景定义为您的 ImageButton:

 android:background="@android:color/transparent"

您看到的是原始按钮,您的 src 只是被覆盖了。

试试这个

android:background="@null"

这将使您的图像按钮没有背景。

两种代码都适用于您的查询:

android:background="@null"

android:background="@android:color/transparent"

使用这个

 style="?android:attr/borderlessButtonStyle"