android scroll - Check if items are completely visible in the RecyclerView -


i'm trying check if specific items visible in recyclerview; couldn't implement that. please me determine if items visible in recyclerview.

mrecylerview.addonscrolllistener(new recyclerview.onscrolllistener() {     @override     public void onscrolled(recyclerview recyclerview, int dx, int dy) {         super.onscrolled(recyclerview, dx, dy);         linearlayout ll = (linearlayout) recyclerview.findchildviewunder(dx, dy);         if (ll != null) {             texturevideoview tvv = (texturevideoview) ll.findviewbyid(r.id.croptextureview);         }     } }); 

i want check if tvv view visible within mrecyclerview view.

you make logic using layoutmanager api last visible item position in recyclerview onscrolled method:

((linearlayoutmanager) vyourrecycler.getlayoutmanager()).findlastcompletelyvisibleitemposition(); 

from documentation: returns adapter position of last visible view. position not include adapter changes dispatched after last layout pass.

try use , notify recyclerview adapter refresh.

note: don't know why you're using findviewbyid in onscrolled method, work should implemented in recyclerview viewholder performance


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -