如何在RecyclerView的列表边框外添加项目透明度?

Nat*_*sha 16 android android-animation android-layout android-recyclerview

RecyclerView项目超出列表边界时,如何使项目顺利消失?见下图.所有可能的解决方案高度赞

在此输入图像描述

注意:具有渐变背景(阴影模仿)的View上面的解决方案RecyclerView不能很好地工作,因为我在屏幕上有渐变背景,很难将"阴影"视图背景与屏幕背景相匹配,它看起来像这样:在此输入图像描述

所以,像阴影一样的工作不像消失.

更新:获得第二个屏幕,背景如下:

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
    <gradient
        android:type="linear"
        android:startColor="#FF14141d"
        android:endColor="#0014141d"
        android:angle="270"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

这是原始屏幕背景

在此输入图像描述

d.g*_*vci 17

如果你想淡化边缘,你可以使用:

 <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:requiresFadingEdge="vertical" <-- this line
        android:fadingEdgeLength="150dp" <-- this line, the height of fade 
/>
Run Code Online (Sandbox Code Playgroud)