i'm trying to show percentage of scrolling automatically to end of recylerview item by this code:
visibleItemCount = bookContentLayoutManager.getChildCount();
totalItemCount = bookContentLayoutManager.getItemCount();
firstVisibleItem = bookContentLayoutManager.findFirstVisibleItemPosition();
float percentage = (visibleItemCount * 100 / totalItemCount);
Log.e("percent ", percentage + "");
but it doesn't correct and i'm trying to find whats is solution of that, it means show percentage of current scrolled recyclerview items
Recyclerview provides the following methods for vertical and horizontal scroll use the below code,
int offset = recyclerView.computeVerticalScrollOffset();
int extent = recyclerView.computeVerticalScrollExtent();
int range = recyclerView.computeVerticalScrollRange();
float percentage = (100.0f * offset / (float)(range - extent));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With