2015-04-21 70 views
0

http://i.imgur.com/WCGjcOe.pngAndroid - 如何删除图像按钮上的丑陋边框?

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

图片(.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" /> 
+0

你可以用'ImageView',而不是它,否则设置'机器人:background =“@ android:color/transparent”'图片按钮。 – Piyush

+0

您可以使用边界宽度和描边宽度等于0的xml创建一个形状。 – Nepster

+0

@Nepster无需执行那么长的代码。透明背景将起作用。 – Piyush

回答

3

你必须定义XML属性背景,你ImageButton

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

你看到的是原始的按钮,你的src只是覆盖。

+0

谢谢,这正是我在找的东西:) – Danieboy

2

试试这个

android:background="@null" 

这会让你的ImageButton没有背景。

+0

它应该是一条评论 – Nepster

+1

为什么发表评论?这是一个可行的解决方案... – Opiatefuchs

+0

请澄清这个问题?我已经回答了他的问题。 –

2

两个代码工作的优良查询:

android:background="@null" 

OR

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

谢谢,这工作太:) – Danieboy

1

使用此

style="?android:attr/borderlessButtonStyle"