0

I have added a custom fast scroller for recyclerview in my application. But the problem is, the fast scroller keeps showing even if the content of the recyclerview is very less. Can anyone suggest me any way, to initially check if the recyclerview is scrollable or not.Also i need to check this inside the custom view itself rather than in any activity/fragment where it is called. Note: I already tried getting recyclerview's adapter.Itemcount or recyclerview.computeverticalscrollrange in the onlayout or onsizechanged method of my custom view but initally both are returning 0. Thank you

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Allan Antony
  • 21
  • 1
  • 5

1 Answers1

0

Why is it a problem that the initially returned value is 0? Just re-evaluate whether the fast-scroller should be enabled every time you change the content of the recyclerview

Nino van Hooff
  • 3,677
  • 1
  • 36
  • 52
  • That is what i wanted to know? on which override should i evaluate? Because onlayout keeps getting called everytime i scroll and the onsizechanged gets called only during intialilzation time which returns me with 0. – Allan Antony Dec 04 '21 at 04:28
  • Assuming you know the item count in your viewmodel, add a function to your viewmodel that returns whether or not to show the thumb. Use this function in the fragment to determine whether to show or hide the thumb – Nino van Hooff Dec 04 '21 at 17:41
  • I know we can control the visibility of thumb with the data available in the activity/fragment, but as i said in my question , i want to handle that case inside my custom fast scroller view. The reason i need this is , because i will be using this view in lots of pages. So i don't want to waste time by checking data in each and every class it is being called. – Allan Antony Dec 06 '21 at 12:00