最近使用 SpringAnimation
对 ExpandableListView
添加回弹效果。
开始使用 scrollY
进行判断,无奈每次获取到的值始终为0,后采用下面这种方式:
val isOnTop get() = firstVisiblePosition == 0 && getChildAt(0)?.top == top + paddingTop
val isOnBottom get() = lastVisiblePosition == count - 1 &&
getChildAt(childCount - 1).bottom <= bottom - paddingBottom
可在 setOnScrollListener()
或 onTouchEvent()
中监听