recyclerview react inside example entre ejemplo diferencia android android-nestedscrollview

android - react - recyclerview inside scrollview



¿Cómo detectar la posición del scroll nestedscrollview android en la parte inferior? (3)

solo quiero detectar la posición del scroll nestedscrollview android en la parte inferior, y la función para llamar. mi código es:

scroll.getViewTreeObserver() .addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { int totalHeight = scroll.getChildAt(0).getHeight(); int scrollY = scroll.getScrollY(); Log.v("position", "totalHeight=" + totalHeight + "scrollY=" + scrollY); if (scrollY==totalHeight) { getPlaylistFromServer("more"); } } });

Pero la altura total no es lo mismo con MAX ScrollY. Como arreglarlo ?


Establezca setOnScrollChangeListener en un NestedScrollView para obtener

  • NestedScrollView v (padre con desplazamiento)
  • int scrollY
  • int oldScrollY

Para detectar si el desplazamiento está en la parte inferior, es necesario obtener el valor de altura de contenido v.getChildAt(0).getMeasuredHeight() y comparar el desplazamiento actual sobre la altura del padre, si tiene el mismo valor, Significa que ha llegado al final.

Puede obtener la altura con la vista principal con v.getMeasuredHeight()

NestedScrollView scroller = (NestedScrollView) findViewById(R.id.myScroll); if (scroller != null) { 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.getMeasuredHeight() - v.getChildAt(0).getMeasuredHeight() )) { Log.i(TAG, "BOTTOM SCROLL"); } } }); }


Sé que es tarde pero ... intente de esta manera.

scroll.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { View view = (View) scroll.getChildAt(scroll.getChildCount() - 1); int diff = (view.getBottom() - (scroll.getHeight() + scroll .getScrollY())); if (diff == 0) { getPlaylistFromServer("more"); } } });

Feliz codificación ..


@Override public void onScrollChange(NestedScrollView nestedScrollView, int scrollX, int scrollY, int oldScrollX, int oldScrollY) { if (nestedScrollView.getChildAt(nestedScrollView.getChildCount() - 1) != null) { if ((scrollY >= (nestedScrollView.getChildAt(nestedScrollView.getChildCount() - 1).getMeasuredHeight() - nestedScrollView.getMeasuredHeight())) && scrollY > oldScrollY) { LogsUtils.INSTANCE.makeLogD(">onScrollChange>", ">>BOTTOm"); } } }

Funcionó para mí, Source