23

I have searched and tryed all found solutions to this. I need to remove the shadow from a button in android. Most of the solutions i found involve using an imagebutton and setting it's background. I tryed that and it works but my button has text so imagebutton is not an option. Unless there is a way to write to an imagebutton?

My second solution was:

android:fadingEdgeLength="0dp"

But nothing seemed to change. Third:

android:shadowColor="@color/application_transparent" />

Nothing changed here either.

I also tryed creating a custom shape with stroke 0 and setting the buttons background to it but still nothing. I prefer to do this in my Xml rather than programmatically but if that is the only way, so be it. Thanks in advance

Scottyers
  • 261
  • 1
  • 2
  • 6
  • just make your own 9patch image? – A.S. Feb 26 '15 at 14:13
  • With the text as an image? I thought of that as a last resort because i am going to translate the app into different languages and that would complicate the translation process by far because i would have to edit each image individually rather than just the strings file. Is this the only way? – Scottyers Feb 26 '15 at 14:15
  • no just a background image for the button – A.S. Feb 26 '15 at 14:15
  • Sorry i don't fully understand. My button background is just simple red color. But il'l give it a shot – Scottyers Feb 26 '15 at 14:18
  • could you share a screenshot? – A.S. Feb 26 '15 at 14:22
  • I used a TextView, instead of a Button. Now the annoying shadow on the button, with a custom background and state list, is completely gone ! This seems like a Lollipop "feature". I call it another "challenge to get around a nuisance" – Someone Somewhere Sep 28 '15 at 14:44

4 Answers4

71

How about

        <Button
           ..<code>

            android:stateListAnimator="@null"

           ..<code>
       </Button>
Vrashabh Irde
  • 14,129
  • 6
  • 51
  • 103
3

Set Style Attribute for Button in xml

style="?android:attr/borderlessButtonStyle"

It Works.

logeshpalani31
  • 1,416
  • 12
  • 33
0

In my case, simply adding..

android:shadowRadius="0"

..in the xml file did the trick.

Henrique de Sousa
  • 5,727
  • 49
  • 55
0

Alternative for Attribute stateListAnimator used in API level 21 - I wrapped button inside a linear layout, both having same dimensions. Worked for my case.

gaurav.28ch
  • 39
  • 2
  • 6