Android how to set a button to have a transparent background but outline

When I set android:background="@android:color/transparent, it sets the background transparency of the buttons, but the outline of the button disappears. How to set it so that the background is transparent, but still have an outline?

+5
source share
2 answers

You can use a custom selector that uses different nine patch images for different button states.

This link may be useful.

You can use this image ...

enter image description here

Hope this helps.

+4
source

One approach is to make a 9 patch that has a border but transparency in the middle.

Here is an example:

Example 9-patch

11x11 2 ​​. png draw9patch , pppppppppppp

android:background="@drawable/bground"

9- "bground", , , , .

0

All Articles