android - 我只想在左右角添加阴影

标签 android listview shadow

我已经尝试对 ListView 进行阴影处理,我可以制作所有四个边。但是我在这里只需要对 ListView 的左右角进行阴影处理,如下图所示:

enter image description here

最佳答案

我觉得可以用覆盖的方式,前景层覆盖在背景层上,设置前景层的padding,让背景层只暴露在渐变边缘。

<?xml version="1.0" encoding="utf-8"?>  
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >  
    <!-- layout background -->  
    <item>  
        <!-- show rectangle area -->  
        <shape android:shape="rectangle" >  
            <gradient  
                android:angle="270"  
                android:startColor="#FFFFFF"  
                android:centerColor="#000000"  
                android:endColor="#FFFFFF"/>  
        </shape>  
    </item>  
    <!-- layout foreground -->  
    <item  
        android:bottom="5px"  
        android:top="5px">  
        <!-- show rectangle area -->  
        <shape android:shape="rectangle" >  
            <solid android:color="#FFFFFF" />  
        </shape>  
    </item>  
</layer-list>  

也可以使用Layer-List具体引用SDK文档

关于android - 我只想在左右角添加阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41299262/

相关文章:

android - 将数据从 Activity 传递到 android 中的 fragment 不起作用

c# - 只写入 listView 中的一列?

html - CSS 阴影覆盖 div/content

ios - 使用 UIBezierPath 和阴影查看?

java - 使用 PHP 将数据从 Android 发送到 SQL 数据库

java - 我的项目不想完成同步

c# - 如何从 C# 中的 ListView 写入 XML 文件

iphone - 为 UIWebView 和 UITextView 添加阴影

android - 在库模块中使用 Google Play Services Gradle 插件

android - 当我滚动 ListView 时,项目在 ListView 中的位置正在改变