2017-01-13 4 views
1

Ich verwende RecyclerView innerhalb NestedScrollView. Für smooth scrollingScrollListener für RecyclerView in NestedScrollView?

nestedScrollView.setNestedScrollingEnabled(true); 
recyclerView.setNestedScrollingEnabled(false); 

Und das RecyclerView ist dynamisch, dynamisch Zeilen auf dem scroll hinzufügen. Aber Scroll-Listener funktioniert nicht NestedScrollingEnabled ist falsch.

Antwort

1
 scroller.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() { 
      @Override 
      public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) { 

       if (scrollY > oldScrollY) { 
        Log.i(TAG, "Scroll DOWN"); 
       } 
       if (scrollY < oldScrollY) { 
        Log.i(TAG, "Scroll UP"); 
       } 

       if (scrollY == 0) { 
        Log.i(TAG, "TOP SCROLL"); 
       } 

       if (scrollY == (v.getChildAt(0).getMeasuredHeight() - v.getMeasuredHeight())) { 
        Log.i(TAG, "BOTTOM SCROLL"); 
    f (viewGroup1.getChildAt(viewGroup1.getChildCount() - 1) instanceof RecyclerView){ 
//add code here } 

       } 
      } 
     }); 
+0

Gültig nur für API 23 und höher. – Galya

+0

nette Lösung .. es funktioniert gut –

Verwandte Themen