关于Android中的elevation阴影显示条件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37840482/article/details/77640255

近两天使用elevation时,发现有时不能绘制出阴影。经过多次实验,发现使用elevation时有以下要求:

1. 控件必须设置背景色,且不能为透明。

2. 阴影是绘制于父控件上的,所以控件与父控件的边界之间需有足够空间绘制出阴影才行。

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal"
        android:background="@color/white"
        android:elevation="3dp"
        >

记录一下,备忘.....

猜你喜欢

转载自blog.csdn.net/qq_37840482/article/details/77640255