Android elevation无法使用深色背景色

Android elevation无法使用深色背景色,android,Android,我试图用上面的代码添加一个下拉阴影,但是如果背景颜色是暗的,我就看不到阴影。但是如果颜色是白色,它就可以正常工作 请不要建议使用或drawable。我需要使用轮廓和立面。您可以将视图包装在cardview中以获得阴影效果 如果要更改卡的背景色,请使用: <LinearLayout android:id="@+id/headerContainer" android:layout_width="match_parent" android:layo

我试图用上面的代码添加一个下拉阴影,但是如果背景颜色是暗的,我就看不到阴影。但是如果颜色是白色,它就可以正常工作


请不要建议使用
或drawable。我需要使用轮廓和立面。

您可以将视图包装在cardview中以获得阴影效果

如果要更改卡的背景色,请使用:

<LinearLayout
        android:id="@+id/headerContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:background="@color/dark_green"
        android:elevation="32dp"
        android:outlineProvider="background"/>
像这样:

app:cardBackgroundColor="@somecolor"


你确定没有阴影吗?有时很难发现,因为默认情况下阴影是透明的黑色。最简单的确认方法是截图并在位图编辑器中检查。是的,我确定。屏幕背景为白色,以便看到阴影
<android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardBackgroundColor="@color/white">

</android.support.v7.widget.CardView>