listview 模仿 ios阻尼效果(学习)

package com.cn.zjy;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.widget.ListView;


@SuppressLint("NewApi")
public class DampList extends ListView {

private static final int OVER_SCROOL_DISTANCE = 200;
private Context mContext;
private int mMaxYOverscrollDistance;

public DampList(Context context) {
super(context);
mContext = context;
initDampList();
}

public DampList(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mContext = context;
initDampList();
}

public DampList(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
initDampList();
}

private void initDampList() {
final DisplayMetrics metrice = mContext.getResources().getDisplayMetrics();
final float distance = metrice.density;
mMaxYOverscrollDistance = (int) (distance*OVER_SCROOL_DISTANCE);
}

@Override
protected boolean overScrollBy(int deltaX, int deltaY, int scrollX,
int scrollY, int scrollRangeX, int scrollRangeY,
int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) {
// TODO Auto-generated method stub
return super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX,
scrollRangeY, maxOverScrollX, mMaxYOverscrollDistance, isTouchEvent);
}


}

你可能感兴趣的:(listview 模仿 ios阻尼效果(学习))