I need a function which returns a boolean if my screen is scrollable inside a NestedScrollView. I currently have a RecyclerView inside a NestedScrollView and the content of the RecyclerView is dynamic (i can add or remove items). Everytime i swipe to delete i want to call the function which checks if the NestedScrollView is scrollable. I am currently using this function:
fun isRecyclerScrollable(binding: FragmentToBuyBinding): Boolean {
val e = requireActivity().findViewById<NestedScrollView>(R.id.nested)
return e.canScrollVertically(1) || e.canScrollVertically(-1)
}
This works but with a flaw. Upon deleting the last content in my RecyclerView which makes the screen not scrollable, the function still returns true. However, after that, every deletion i perform, it returns false. But this is not good and i need it to return false the moment my screen is not scrollable. Can you help ?