主要使用overScrollBy 方法,前提是必须填满整个屏幕才有效果
package com.weidingqiang.customlistview; import android.content.Context; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.widget.ListView; /** * Created by weidingqiang on 15/11/28. */ public class ListViewMove extends ListView { private static final int MAX_Y_OVERSCROLL_DISTANCE = 200; private Context mContext; private int mMaxYOverscrollDistance; public ListViewMove(Context context) { this(context, null); } public ListViewMove(Context context, AttributeSet attrs) { super(context, attrs); mContext = context; initBounceListView(); } private void initBounceListView(){ final DisplayMetrics metrics = mContext.getResources().getDisplayMetrics(); final float density = metrics.density; mMaxYOverscrollDistance = (int) (density * MAX_Y_OVERSCROLL_DISTANCE); } @Override protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent){ return super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, scrollRangeY, maxOverScrollX, mMaxYOverscrollDistance, isTouchEvent); } }
原文:http://www.cnblogs.com/weidingqiang/p/5002610.html