浮动操作按钮,无阴影显示 [英] Floating Action Button no shadow showing

查看:111
本文介绍了浮动操作按钮,无阴影显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在浮动动作"按钮下添加阴影,但该阴影未显示.

I am trying to get a shadow under my Floating action button but its not showing.

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="20dp"
    android:background="@color/colorAccent"
    android:clickable="true"
    android:scaleX="-1"
    android:src="@drawable/ic_share"
    app:borderWidth="0dp"
    app:elevation="21dp"
    app:fabSize="normal"
    app:itemIconTint="@color/white" />

<Custom View/>

这是现在的显示方式:

This is how it shows now:

我在做什么错了?

建议添加app:borderWidth ="0dp"的修复方法不能解决我的问题

Edit 1: The suggested fix to add app:borderWidth="0dp" doesn't fix my problem

显然使用android:scaleX =-1"解决的问题消除了阴影

Edit 2: Problem solved apparently using android:scaleX="-1" removes the shadow

推荐答案

您只需要将app:borderWidth="0dp"添加到FloatingActionButton

示例代码

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="20dp"
    app:borderWidth="0dp"
    android:background="@color/colorAccent"
    android:clickable="true"
    android:src="@drawable/ic_share"
    app:borderWidth="0dp"
    app:elevation="21dp"
    app:fabSize="normal"
    app:itemIconTint="@color/white" />

并确保

在应用程序"标签中检查清单文件并将其删除

Check manifest file in Application tag and delete them

android:hardwareAccelerated="false"
android:largeHeap="true"

但是,如果您需要这些选项,则阴影和变换动画将不起作用

But if you need these options then shadows and transformation animations will not work

这篇关于浮动操作按钮,无阴影显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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