How to find out if ListView has scrolled to top Most position?

后端 未结 10 827
情歌与酒
情歌与酒 2020-12-29 03:09

I have a ListView, first its scrolled down, now when we scroll up,it reach top most point. I want to detect that .Is there any way?I am developing application with api level

10条回答
  •  囚心锁ツ
    2020-12-29 04:05

    Too late but try this one it works well in RecyclerView. -1 to check if it can scroll to top while 1 is to check if it can scroll to bottom

    if (listView.canScrollVertically(-1))
       listView.smoothScrollToPosition(0);
    else
       onBackPressed();
    

提交回复
热议问题