'How to check whether nested scroll view is scrollable or not after rendering the list/items in UI without user action in android?

I m using recycler view with nested scroll view on top, but recycler view i have nested scroll enabled as false in xml & i m dependent on nested scroll view for scrolling.Now i need to check on rendering items on ui i can check whether the view is scrollable or not pragmatically in android?

How to check whether recycler view is scrollable or not after rendering the list/items in UI without user action in android?

How to check view is scrollable or not without any user action on rendering the items in UI in android?

I m stuck on this issue.

Any help is appreciated!



Solution 1:[1]

You can check is view is scrolling or not by using below code

mNestedScrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
            @Override
            public void onScrollChanged()
            {
                // you can do whatever you want on scroll changed here.
                
                
                // And if you want to know whether view is at the bottom, then use below code
                View view = mNestedScrollView.getChildAt(mNestedScrollView.getChildCount() - 1);
                int diff = (view.getBottom() - (mNestedScrollView.getHeight() + mNestedScrollView
                        .getScrollY()));
                if (diff == 0) {
                    // Scrolled to bottom of the view.
                }
            }
        });

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shivam Jamaiwar