This has been asked before by Daren (here
http://groups.google.com/group/android-developers/browse_thread/thread/ab41256a0f57cd44/0c082d62ed206733
and here 
http://groups.google.com/group/android-developers/browse_thread/thread/3e6276e775b9685b/8b37670956c9b03f)
and even though Romain Guy replied, his replies didn't really answer
the questions.  Here's another try:

When doing scrolling animation in View's computeScroll(), we cannot
access the members mScrollX and mScrollY directly.  They are hidden
from the API;  funnily enough, Google doesn't seem to eat their own
dog food, meaning, they don implement their own apps against the API.
For instance, Launcher and Launcher2 both access these members
directly to create Android's home screen flinging (http://
android.git.kernel.org/?p=platform/packages/apps/
Launcher2.git;a=blob_plain;f=src/com/android/launcher2/
Workspace.java;hb=master).

Instead of accessing these members, one should call scrollTo() with
the desired X and Y parameters.  scrollTo() then in turn calls
invalidate() which should make the screen being redrawn and
computeScroll() being called again, thus, creating a sort of animation
loop.  Unfortunately, as Daren pointed out, invalidate() does not seem
to cause computeScroll() being called again.  Nothing animates.
Calling postInvalidate() however does the trick.  Hence, my current
workaround is to call scrollTo(), followed by postInvalidate().  This
seems ugly since now both invalidate() and postInvalidate() are being
called at the same time.

>From looking at the postInvalidate() code I don't see how it is any
different from invalidate().  It is simply an invalidate() call posted
into the main thread's message queue.

1. Can anyone clarify why postInvalidate() works, while invalidate()
doesn't?

2. What is the correct way to implement computeScroll(), without
calling both invalidate() and postInvalidate()?

Thanks,
-Jonas

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to