how to detect the position of the scroll nestedscrollview android at the bottom?

后端 未结 7 980
不知归路
不知归路 2020-12-04 22:19

i just want to detect the position of the scroll nestedscrollview android at the bottom, and the to call function. my code is :

scroll.getViewTreeObserver()
         


        
相关标签:
7条回答
  • 2020-12-04 22:49

    I know it's late but.. try this way.

    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");
                }          
        }
    });
    

    Happy Coding..

    0 讨论(0)
提交回复
热议问题