【发布时间】:2017-01-23 13:29:42
【问题描述】:
我创建移动图像背景的视差效果仅取决于回收站视图的第一个元素的位置。
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if ((holder = recyclerView.findViewHolderForAdapterPosition(0)) != null) {
int offset = recyclerView.findViewHolderForAdapterPosition(0).itemView.getTop() / 10;
backgroundPhoto.setTop(offset);
}
问题是:当 recycler(header) 的第一项滚动离开屏幕时,背景图片会以某种方式跳到初始位置。
【问题讨论】:
标签: android scroll android-recyclerview parallax