2017-01-13 1 views
1

J'utilise RecyclerView à l'intérieur NestedScrollView. Pour un défilement fluideScrollListener pour RecyclerView à l'intérieur de NestedScrollView?

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

Ce RecyclerView est dynamique, en ajoutant dynamiquement des lignes sur la scroll. Mais l'écouteur de défilement ne fonctionne pas NestedScrollingEnabled est faux.

Répondre

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

Valable uniquement pour l'API 23 et les versions ultérieures. – Galya

+0

belle solution .. ça marche bien –