FireFly3000 FireFly3000 - 1 year ago 167
Android Question

How to remove border/shadow from lollipop buttons

The buttons looks fine for api < 21. However, the +21 versions creates this border or shadow that is shown on the image below. How do I get rid of it without changeing the hole theme, but setting a style variable?

enter image description here

It might be more clear on this colored image. There is some kind of border around the buttons.
enter image description here

My buttonssstyle is defined like this:

<style name="buttonTransparent" parent="Base.TextAppearance.AppCompat.Button">
<item name="android:background">#00000000</item>
<item name="android:textColor">@drawable/button_text_blue</item>
<item name="android:textSize">18dp</item>
<item name="android:textAllCaps">false</item>
<item name="android:minHeight">45dp</item>

<style name="buttonLargeWhite" parent="buttonTransparent">
<item name="android:background">#FFF</item>
<item name="android:layout_marginTop">10dp</item>

Answer Source

Lollipop has a nasty little feature called stateListAnimator which handles the elevations on Buttons, which leads to shadows.

Remove the stateListAnimator to get rid of the shadows.

You have got multiple options to do that:

In code:


or in your layout xml's:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download