Android: Listview's bounce to scrollview

后端 未结 6 1032
生来不讨喜
生来不讨喜 2021-02-02 00:33

Any way of adding ListView\'s bounce effect to regular scrollview? By bounce I mean the rubber band like effect when you hit the bottom of the list.

6条回答
  •  忘了有多久
    2021-02-02 00:48

    For those who want to implement the bounce effect on ListView.

    Howto

    one way to add this effect is using addHeaderView and addFooterView in ListView, and their padding(topPadding for header view, and bottomPadding for footer view) are set to 0 for the first time, then we override the onTouchEvent, and change the padding according to the moving distance.

    Implementation

    Sample Code

    Notes

    The idea is borrowed from android-pulltorefresh, since bouncing effect are more simple than pull-to-refresh, so the code is shorter too. ^_^

    Hope this will help someone..

提交回复
热议问题