0

I have this code addOnScrollListener of recyclerview which is inside a nestedscroll view

 mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                mScrollState = newState;
                if (newState == RecyclerView.SCROLL_STATE_IDLE && adapter.getItemCount() > 0) {
                    mCalculator.onScrollStateIdle();
                }
            }

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                mCalculator.onScrolled(mScrollState);
            }
        });

i need to get into those methods in addOnScrollListener when i scroll my view. But unfortunately, while scrolling not entering this methods. can anyone help me how to get scroll of recyclerview inside the nested scrollview

Jins Lukose
  • 689
  • 6
  • 19

2 Answers2

0

behalf of new RecyclerView.OnScrollListener() try to use NestedScrollView.OnScrollChangeListener. It might be help you to solved your issue

nestedScrollView.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, x, y, x1, y1) -> {
            if(v.getChildAt(v.getChildCount() - 1) != null) {
                if ((x >= (v.getChildAt(v.getChildCount() - 1).getMeasuredHeight() - v.getMeasuredHeight())) &&
                        y > y1) {
                        //code to fetch more data for endless scrolling
                }
            }
        });
Peter
  • 380
  • 3
  • 11
  • sorry not helping. the thing is my list consist of text,images and videos three layout are there.when the user scroll and reach video where video is fully visible for user the video should play automatically. For that i need the recyclerview scroll – Jins Lukose Sep 05 '18 at 08:57
0

I just handled issue by using gesture motion

Jins Lukose
  • 689
  • 6
  • 19