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?
It might be more clear on this colored image. There is some kind of border around the buttons.
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>
I fixed this globally by setting
android:stateListAnimator="@null"
inResources\values\styles.xml
:And voila the shadows are gone for good :)
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
Issue
From Android v21, Border has been added by default for all the button.
Solution
In our application theme, set button style to remove the default border (Android support library itself provides style for it).
There is already a style you can leverage not to have the borders.
apply
to your item to remove the borders
in xml we can use
If you want to do this programmatically in Kotlin, you can do