[英]the edge of a Button still has a light grey line around it while the edge of it has the same color of background
I set a Gradient for a Button with Color Red and edge Color of Red too,我为按钮设置了一个渐变,颜色为红色,边缘颜色为红色,
The Button is placed inside a Linear Layout with Red color too按钮也放置在红色的线性布局内
The problem is the edge of the Button still has a light grey line around it问题是 Button 的边缘周围仍然有一条浅灰色的线
Why?为什么?
Since the edge is Red there should be no edge seen由于边缘是红色的,所以应该看不到边缘
As is seen in the image, when edge is green still a grey thing is seen如图所示,当边缘为绿色时,仍然可以看到灰色的东西
It's the default shadow of button in material design guidelines.它是材料设计指南中按钮的默认阴影。 To remove it put this attribute in your
<Button
element:要删除它,请将此属性放在
<Button
元素中:
android:stateListAnimator="@null"
Or, programmatically, you can do it in this way:或者,以编程方式,您可以这样做:
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { //Check if it's supported
yourButton.setStateListAnimator(null);
}
You can try to add this code to your button's xml您可以尝试将此代码添加到按钮的 xml
style="?android:attr/borderlessButtonStyle"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.