Question: I have used [OverScroller](http://developer.android.com/reference/android/widget/OverScroller.html) for implementing scroll of my view. 

Here is some code:

```
@Override
protected void onDraw(Canvas canvas) {
    if (scroller.computeScrollOffset()){
        int x = scroller.getCurrX();
        int y = scroller.getCurrY();
        scrollTo(x, y);

        ViewCompat.postInvalidateOnAnimation(this);
    }

    super.onDraw(canvas);
}

public void open(){
    scroller.startScroll(0, 0, 0, -mContent.getMeasuredHeight(), ANIMATION_TIME);
    invalidate();
}

public void close(){
    scroller.startScroll(0, getScrollY(), 0, mContent.getMeasuredHeight(), ANIMATION_TIME);
    invalidate();
}

```

It works fine. But on device with Full HD screen (Sony xperia Z) the method onDraw calls 4 times. On "Samsung Galaxy Note 2" it calls about 10 times. Hence on xperia i see lags. What can i do to improve performance ?

**UPD:** Here is full code <http://xsnippet.org/359714>

Answer: 
you should override computeScroll() for things like that and not onDraw()
You can override **onFinishInflate ()** method in your custom View class and you can write OverScroll related code under this method instead of **onDraw()**. For more detail [click here](http://developer.android.com/reference/android/view/View.html#onFinishInflate%28%29).