如何从棒棒糖按钮删除边框/阴影 [英] How to remove border/shadow from lollipop buttons

查看:114
本文介绍了如何从棒棒糖按钮删除边框/阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于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" 
....
/> 

这篇关于如何从棒棒糖按钮删除边框/阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆