Horizontal recyclerview with fading edges

落爺英雄遲暮 提交于 2019-12-28 13:36:07

问题


If I look at the stackoverflow app's horizontal recyclerview, I can see that they use the "fading edge" technique so that the user will know that there are items on the left and right of the recyclerview and he / she can scroll.

In listview, I think this effect is enabled by calling the below as described by Romain Guy (http://www.curious-creature.com/category/android/page/2/):

android:cacheColorHint="#00000000"

No such option exist in Recyclerview unfort. Is there a built in method to allow for these fading edges for recyclerview or will it just have to be a hack?


回答1:


I think the attribute you are looking for is:

android:requiresFadingEdge="horizontal|vertical"

you can search and better understand this attribute from the recycler view's documentation.

The other attribute you are talking about, 'cacheColorHint', can be used to match the fading color with that of your background. This attribute is the color upon which the list view is drawn, and is defined as an opaque color, because you don't always have a white background (which I think is the default color... but I'm not sure), the best option is to use a transparent color, "#00000000", as suggested by Romain Guy.

Hopefully this is what you are looking for!

Cheers



来源:https://stackoverflow.com/questions/33720836/horizontal-recyclerview-with-fading-edges

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!