1

As you know, buttons in API+21 raise when you touch them. According to the documentation, you should not place such buttons in dialogs or other raised interfaces. I have tried setting elevation to 0 or 1 but to no avail. I just want the button to have the ripple effect without raising. How can I do that?

<Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:elevation="0dp"
            android:clickable="true"/>
Edric
  • 21,480
  • 12
  • 75
  • 86
Sean Goudarzi
  • 1,094
  • 1
  • 8
  • 22

1 Answers1

4

Referring to his answer here: https://stackoverflow.com/a/31003693/3090173. It says to set the button's stateListAnimator to null via the xml attribute.

<Button
   ....
   android:stateListAnimator="@null" 
   .... />

You can also set a custom drawable as the background to get rid of the elevation.

Boken
  • 4,062
  • 9
  • 31
  • 41
crymson
  • 1,160
  • 7
  • 12