标签:
public class MyViewGroup extends LinearLayout { private boolean recover=true; Scroller mScroller=null; public MyViewGroup(Context context, AttributeSet attrs) { super(context, attrs); mScroller=new Scroller(context); } //实际发生滚动的函数 @Override public void computeScroll() { if (mScroller.computeScrollOffset()) { int deltX=mScroller.getCurrX(); int deltY=mScroller.getCurrY(); scrollTo(deltX, deltY); postInvalidate(); } } public void beginScroll(){ if (!recover) { mScroller.startScroll(0, 0, 0, 0, 10000); recover = true; } else { mScroller.startScroll(0, 0, -100, -100, 10000); recover = false; } invalidate(); } }
Android Scroller类和VelocityTracker类
标签:
原文地址:http://www.cnblogs.com/phenixyu/p/4222448.html