Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>  <style name="buttonLargeWhite" parent="buttonTransparent">         <item name="android:background">#FFF</item>         <item name="android:layout_marginTop">10dp</item>     </style> 
like image 970
7heViking Avatar asked Jun 23 '15 13:06

7heViking


People also ask

How do you remove an elevation button?

try to set android:elevation="0dp" to your main layout.


1 Answers

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:

Java:

button.setStateListAnimator(null); 

Kotlin:

button.stateListAnimator = null 

or in your layout xml's:

<Button ... android:stateListAnimator="@null"  .... />  
like image 131
foxy Avatar answered Oct 02 '22 14:10

foxy