0

I have a ViewGroup (specifically a LinearLayout) which I would like to be clickable, and have the normal click actions/animations (for example, the background color changes just a bit when clicked (pre-Lollipop) and have the ripple animation (Lollipop).

I have an onClickListener setup, and have set clickEnabled to true, but still I get no animation.

How can I get this?

Thanks!

zundi
  • 2,361
  • 1
  • 28
  • 45

1 Answers1

2

Put ?android:attr/selectableItemBackground as your background to support the default click animation.

You can use it in xml like this:

android:background="?attr/selectableItemBackground"
David Medenjak
  • 33,993
  • 14
  • 106
  • 134
  • @sandy try this: http://stackoverflow.com/questions/20531516/how-do-i-add-selectableitembackground-to-an-imagebutton-programatically – David Medenjak Mar 17 '16 at 19:57