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
  • 24,639
  • 13
  • 81
  • 91
Sean Goudarzi
  • 1,244
  • 1
  • 10
  • 23

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,825
  • 10
  • 32
  • 42
crymson
  • 1,170
  • 7
  • 12