Reputation: 3765
I saw a lot of posts that show the currently entirely visible item in the recycler view but, from the activity. But, I want to know about that from the adapter. If the view is completely visible, I want to start playing a video and when it is hidden, I want to stop it.
Upvotes: 0
Views: 1660
Reputation: 19233
you have to set LayoutManager
for RecyclerView
. if you are using most common LinearLayoutManager, then it's have some methods for your purpose:
There are also similar methods in StaggeredGridLayoutManager, e.g. findFirstVisibleItemPositions
And general way would be to use bare LayoutManager
and its isViewPartiallyVisible method, but this probably needs more your code for particular use case
Upvotes: 1