How to control mutlipleview type recyclerview with tab layout?

456 Views Asked by At

i need to handle recycler view with multiple view type(i.e header and item) using tab layout. I have same tabs as header when i tap on tabview any position i made scroll to that position and highlight that particular tab but i also wants to highlight tab while user scrolling through recycler view and which section is visible currently same position from tab layout get selected.

this is how i am doing it right now using scroller listener but it's not working fine

 recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);

            }    
            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
    int firstVisibleItemPosition = manager.findFirstVisibleItemPosition();  
     mTabLayoutRestaurantsCategory.getTabAt(firstVisibleItemPosition).select();

            }
        });
0

There are 0 best solutions below