7

Possible Duplicate:
ImageButton doesn’t highlight on click with Transparent background

I have made a custom bar where I have buttons with the attribute

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

My problem is that when I click on the buttons the click effect does not trigger(in this case the button should become and blue and fade back in its original color -transparent here-).

How do I enable it or just simulate the effect? Any ideas?

Community
  • 1
  • 1
MayTheSchwartzBeWithYou
  • 1,181
  • 1
  • 16
  • 32

2 Answers2

8

Seems transparent is a bad option. Better have

style="?android:attr/borderlessButtonStyle"

same effect, without needing to go through creating another custom xmls

MayTheSchwartzBeWithYou
  • 1,181
  • 1
  • 16
  • 32
2

You need to use selector check: http://developer.android.com/guide/topics/ui/controls/button.html under "Custom background"

TOMKA
  • 1,096
  • 13
  • 24
  • I need to use it in what way? To put the "transparent" in there? – MayTheSchwartzBeWithYou Oct 14 '12 at 11:51
  • The selector defines the drawable to use it each state of the button, so your active state should be transparent but your selected (and focused) state should be the blue you need, so you can give it as a color or a drawable. – TOMKA Oct 15 '12 at 14:07