Reputation: 7331
I have got a recycler view that shows a list of images. I have added an onScrollListener to that recycler view.
Now, when a scroll is detected, I would like to set the translation of the imageviews in the viewholders. Therefore I need a reference to the underlying view holders.
How can I get those?
In code (this won't work, but you will get the idea what I want to achieve):
ImageView imageView = (ImageView) ((RecyclerFragmentAdapter.MyViewHolder)
mRecyclerView.getChildAt(i)).itemView.findViewById(R.id.imageView);
// ... Modify imageview, i.e. imageView.setImageMatrix(customImageMatrix);
Upvotes: 4
Views: 4849
Reputation: 664
RecyclerView.getChildViewHolder()
RecyclerView.findViewHolderForAdapterPosition()
RecyclerView.findViewHolderForLayoutPosition()
Upvotes: 6