自从升级到SDK 21以来,我一直在尝试使用elevation属性,但它似乎从未起过作用。
我希望将一个帧提升到其他帧之上,因此我设置了以下内容
android:elevation="4dp"但是没有影子的迹象。我已经尝试了按钮和框架布局,但没有得到任何提升
下面是完整的标签
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/panel_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:elevation="4dp"
>我还遗漏了什么我需要补充的东西吗
发布于 2015-02-18 20:54:15
确保存放FrameLayout的容器的背景不透明。
发布于 2014-11-11 18:40:07
根据this Z=高程+ TranslationZ
所以试试这个:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/panel_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:elevation="4dp"
android:translationZ="4dp">发布于 2020-08-13 10:04:31
您需要为其添加类似以下内容的背景:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/panel_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp"
android:background="@drawable/dialog_background">而不是使用白色。否则阴影就不会起作用。此外,是否没有必要使用android:translationZ属性,因为这只会增加标高,但如果您不想要动画,则不是必需的。
https://stackoverflow.com/questions/26812731
复制相似问题