13

RecyclerView項目在離開列表邊界時如何順利消失?見下圖。所有可能的解決方案高度讚賞當RecyclerView超出列表邊界時如何添加項目透明度?

enter image description here

注:解決方案與View上述RecyclerView具有漸變背景(影子模仿)不能很好地工作,因爲我在屏幕上漸變背景,這是難以匹配的「影子」視圖背景到屏幕背景,它看起來像這樣:enter image description here

因此,作品像陰影不像失蹤。

更新:得到了與以下背景的第二個屏幕:

<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> 

這裏是原來的屏幕背景

enter image description here

+0

我是不知道我明白你需要什麼,但爲什麼不使用漸變從完全透明變爲不透明的黑色,高度爲4DP? – npace

+0

@npace,因爲我沒有純色屏幕背景,並且這個解決方案導致了陰影效果(就像在第二張圖片上,在這裏你可以看到更好的http://screencast.com/t/njDZjBkF3la)。它與列表中左右側的屏幕背景具有相同的顏色,但列表中心上的顏色不同。 – Natasha

+0

@npace我需要平面頁面效果,但平滑物品消失。 – Natasha

回答

11
如果你想淡出邊緣

,你可以使用:

<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 
/> 
+1

這正是我所需要的!非常感謝! – Natasha

相關問題