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 th
You can create an xml drawable with button color and set it as a background of the button
I would suggest you just remove the shadow entirely, by setting the elevation to nothing. Since you already have a XML style (add this to use this universally), or you could add this attribute to your XML view definition
android:elevation="0dp"
There is already a style you can leverage not to have the borders.
apply
style="@style/Base.Widget.AppCompat.Button.Borderless"
to your item to remove the borders
Best and easiest way i am using is setting style attribute to Button
<Button
...
style="?android:attr/borderlessButtonStyle"
....
/>
may be someone need in future.
in xml we can use
android:stateListAnimator="@null"
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"
....
/>