How to trigger an event when scrollView reach the bottom with Android?

前端 未结 5 1001
情话喂你
情话喂你 2020-12-10 03:48

Im looking for an event that I can use on the scrollView to be fired when the user has scrolled to the bottom.

E.g my list of items should be extended with more item

5条回答
  •  春和景丽
    2020-12-10 04:09

    It's late for this answer but if anyone stumbles upon, we can do using setOnScrollChangeListener

      childScrollView.setOnScrollChangeListener(object : NestedScrollView.OnScrollChangeListener {
                override fun onScrollChange(v: NestedScrollView?, scrollX: Int, scrollY: Int, oldScrollX: Int, oldScrollY: Int) {
                    when {//maxScrollPixelPoint  is defined local/global variable
                        scrollY > maxScrollPixelPoint -> {
                            maxScrollPixelPoint = scrollY
                        }
                        scrollY == maxScrollPixelPoint -> {
                            //reached bottom 
                        }
                    }
                }
    
            })
    

提交回复
热议问题