今天在Android界面的设计中遇到一个问题,我想要用elevation设置阴影效果,也就是对某个View添加android:elevation
<ListView android:layout_marginLeft="16dp" android:layout_marginRight="16dp" android:padding="8dp" android:id="@+id/action_list_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:elevation="4dp"></ListView>
在Android Studio 的预览上是有阴影的,但是放到模拟器中或者手机中,就没有了,百思不得其解,elevation是Android5.0的特性,我确实是在Android5.0以上的系统允许的出现这种问题就很奇怪了。
经过查询得知,View不能为透明,透明的画就不能画出阴影,只需要添加上背景色即可。
这么想来也是对的,毕竟透明的东西怎么能有阴影呢