Floating Action Button no shadow showing [duplicate]

蹲街弑〆低调 提交于 2019-12-12 04:06:38

问题


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:

What am i doing wrong?

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

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


回答1:


you need to just add app:borderWidth="0dp" to your FloatingActionButton

Sample code

<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" />

and make sure

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



来源:https://stackoverflow.com/questions/46299680/floating-action-button-no-shadow-showing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!