Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓-如何删除图像按钮上丑陋的边框?_Android_Xml_Image_Button_Android Imagebutton - Fatal编程技术网

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

Android 安卓-如何删除图像按钮上丑陋的边框?,android,xml,image,button,android-imagebutton,Android,Xml,Image,Button,Android Imagebutton,非常直截了当的问题-如何删除这些灰色边框 png文件只是星星、文本和周围的白色。然后,当我将它们添加为图像按钮时,它们会添加我真的不想要的丑陋的灰色边框 <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/starButton1" android:src="@drawable

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

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" />

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

您看到的是原来的按钮,您的src刚刚被覆盖。

试试这个

android:background="@null"

这将使您的imagebutton没有背景。

这两个代码对您的查询都适用:

android:background="@null"

用这个

 style="?android:attr/borderlessButtonStyle"

您可以使用ImageView来代替它,否则请设置android:background=@android:color/transparent to image button。您可以在xml中创建一个边框宽度和笔划宽度等于0的形状。@Nepster无需执行长代码。透明的背景可以工作。android:background=@drawable/star\u pink\u 1代替src也可以工作。你说得对,皮尤斯·古普塔。那好吧。没有必要让它变得更难。这应该是一个评论。请用这个来澄清问题?我已经回答了他的问题。谢谢,这正是我想要的:
android:background="@android:color/transparent"
 style="?android:attr/borderlessButtonStyle"