I have this bizarre behaviour when calling invalidate. I have made a custom viewgroup containing a bunch of imageviews.
I set up a onTouch listener with the on touch method to scroll the view. I know all the code is correct in terms of distances to scroll etc. by using logcat.
Now, for some reason the onLayout method is not being called after I call this.invalidate(). When I try to scroll, nothing changes on the screen. However, after I pause the activity and resume it, the screen will have shifted by the amount I scrolled.
I am not blocking the UI thread because there is nothing to block it with. In any case, I have tried postInvalidate() and nothing has worked.
Anybody have any bloody idea what's going on?
1 Answer 1
invalidate() does not relayout the view, it only causes the view to be redrawn. If you want to relayout it (which will invoke onLayout()) you also have to make a call to requestLayout().
invalidate()just redraws theView. It doesn't relayout anything. You need to callrequestLayout()to start a new layouting process.