如何从棒棒糖按钮删除边框/阴影

问题描述:

对于api<而言,按钮看起来不错21.但是,+ 21版本会创建此边框或阴影,如下图所示.如何在不更改Hole主题但设置样式变量的情况下摆脱它?

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.

我的buttonsstyle定义如下:

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>

Lollipop具有一个名为stateListAnimator的讨厌的小功能,它可以处理Button上的高程,从而导致阴影.

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

删除stateListAnimator以消除阴影.

您有多种选择可以做到这一点:

You have got multiple options to do that:

Java:

button.setStateListAnimator(null);

科特琳:

button.stateListAnimator = null

或在布局xml中:

<Button
...
android:stateListAnimator="@null" 
....
/>