android - 使用渐变阴影查看

标签 android xml android-view shadow

我一直在寻找一种方法来为 View 做一些非常简单的 CSS 框阴影,就像灰色背景上的白纸,白色 View 具有渐变阴影。

我已经尝试过使用属性:

android:elevation="Xdp"

设置了背景,但它不起作用。我尝试了很多解决方案,但没有一个有效。

最佳答案

你应该试试 Cardview

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:foreground="?android:attr/selectableItemBackground"
    app:cardCornerRadius="4dp"
    app:cardElevation="4dp"
    android:translationZ="5dp"
    app:cardBackgroundColor="@color/grey_100">

不要忘记依赖

 compile 'com.android.support:cardview-v7:21.0.+'

关于android - 使用渐变阴影查看,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48818119/

相关文章:

android - 如何从 Android 平板电脑与 USB 设备通信?

html - XSLT 抽象

android - 性能 : ViewGroup with Children VS. 自定义绘制 View

java - Android:如何知道运行时小部件应用了哪种样式

android - 替换 View 之间的共享元素转换

一段时间后 Android 通知消失

android - 适用于 Android 的 Flex AIR 应用程序可以作为进程运行吗?

android - 打印机 Bixolon 未连接到 Samsung Galaxy Tab

xml - 根据标签值拆分 XML

xml - 使用 XML::Twig 处理巨大文件 (>10 GB) 的性能问题