开发者

ImageButton Border Transparency - How do I remove the square border around round image?

开发者 https://www.devze.com 2023-02-17 21:28 出处:网络
I think my image is transparent, butI am seeing a grey background appearing around the edges of my image which is round.So instead of nice transparent round Image开发者_如何学编程Button I am seeing sq

I think my image is transparent, but I am seeing a grey background appearing around the edges of my image which is round. So instead of nice transparent round Image开发者_如何学编程Button I am seeing square edges. I need to provide height or it complains but now I have outline of grey/silver square instread of just round image.


Set this attribute in your ImageButton XML android:background="@null"

<ImageButton android:src="@drawable/yourimagename"
     android:id="@+id/thebuttonid"
     android:layout_width = "wrap_content"
     android:layout_height = "wrap_content"
     android:background="@null"
     />


Or just set the background to Android's transparent color

<ImageButton android:src="@drawable/yourimagename"
     android:id="@+id/thebuttonid"
     android:layout_width = "wrap_content"
     android:layout_height = "wrap_content"
     android:background="@android:color/transparent"
     />


You could use ImageButton.setBackgroundResource(int) (android:background attribute) which will get rid of that border.

Costi

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号