如何删除FloatingActionButton周边的影子? [英] How to remove FloatingActionButton's surrounding shadow?

查看:821
本文介绍了如何删除FloatingActionButton周边的影子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图取代第三方 FloatingActionButton 与<一个href="https://developer.android.com/reference/android/support/design/widget/FloatingActionButton.html">the它被包装在图书馆本地之一 com.android.support:design:22.2.0 。默认外观具有图像周围黑暗的阴影,我怎么能摆脱它?我知道,前者提供了与方法 setShadow(),但我就是无法找到与后者相似的。

这是相关的XML布局:

 &LT; android.support.design.widget.FloatingActionButton
        机器人:ID =@ + ID / alarm_front
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:SRC =@可绘制/ btn_icon_alarm_notset/&GT;
 

和我已经设置背景颜色为黄色。

<$p$p><$c$c>mAlarmBtn.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.floatButtonColor)));

解决方案

改写默认的的FAB的加入提升

 安卓海拔=0dp
 

还是在code调用 View.setElevation (浮点)

I'm trying to replace the third party FloatingActionButton with the native one which is packaged in library com.android.support:design:22.2.0.The default look has a dark shadow around the image,How can I get rid of it? I know the former one provides with the method setShadow(),but I just can't find similar one from the latter.

This is the related XML layout:

<android.support.design.widget.FloatingActionButton
        android:id="@+id/alarm_front"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/btn_icon_alarm_notset" />

And I have set its background color to yellow.

mAlarmBtn.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.floatButtonColor)));

解决方案

Override the default elevation of the FAB by adding:

android:elevation="0dp"

Or in code call View.setElevation(float)

这篇关于如何删除FloatingActionButton周边的影子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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