Detecting the scrolling direction in the adapter (up/down)

后端 未结 11 1602
臣服心动
臣服心动 2020-12-01 00:38

I am trying to mimic the Google Plus application in my project, as it seems to be the reference now.

The listview effect when scrolling is really nice and I would li

11条回答
  •  长情又很酷
    2020-12-01 01:07

    I've used this much simpler solution:

    public class ScrollDetectingListView extends ListView
    

    ...

    setOnScrollListener( new OnScrollListener() 
    {
    
        private int mInitialScroll = 0;
    
        @Override
        public void onScroll(AbsListView view, int firstVisibleItem,
                int visibleItemCount, int totalItemCount) 
        {
            int scrolledOffset = computeVerticalScrollOffset();
    
            boolean scrollUp = scrolledOffset > mInitialScroll;
            mInitialScroll = scrolledOffset;
        }
    
    
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
    
    
        }
    
    }
    

提交回复
热议问题