如何添加阴影所提供的支持Android的设计库中的FAB?所提供、库中、阴影、Android

2023-09-12 22:50:23 作者:那一抹少年蓝°

标题是pretty的自我解释。

The title is pretty self explaining.

下面code不渲染阴影之下浮动操作按钮。可以做些什么来渲染阴影?难道这个功能真的不支持甚至在API 21 +?

The following code does not render shadow below the Floating Action Button. What can be done to render shadow? Is this feature really not supported even on API 21+?

<android.support.design.widget.FloatingActionButton
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/ic_add"
    android:clickable="true" />

请注意:添加机器人:海拔不能在API 21添加阴影

Note: Adding android:elevation does not add shadow on API 21.

截图通过dandar3从实例采取: https://github.com/dandar3/android-support-design

Screenshot taken from the example by dandar3: https://github.com/dandar3/android-support-design

推荐答案

简单的设置应用程序:边框宽度=0dp解决这个问题对我来说

Simply setting app:borderWidth="0dp" resolve this issues for me.

注意:不要忘了添加的xmlns:程序=htt​​p://schemas.android.com/apk/res-auto你的根布局。

Note: don't forget to add xmlns:app="http://schemas.android.com/apk/res-auto" to your root layout.

应固定在Android的设计库的下一次发布此问题。

This issue should be fixed in next release of android design library.