My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 16171: Gallery scroll animation stutters when unrelated views are updated
20 people starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


Sign in to add a comment
 
Reported by unwe...@gmail.com, Apr 15, 2011
Please describe the problem in detail. Be sure to include:
- Steps to reproduce the problem (including sample code if appropriate).
  Put a Gallery and another View (say TextView) into the same Activity. Update the other view periodically, say by calling setText() with a countdown. Then scroll the gallery slowly: put your finger down, drag an item ca. 1/2 of the way to when the next item would be centered. Hold until the TextView gets updated.

- What happened.
  The Gallery resets its scroll position, centering the currently selected view.

- What you think the correct behavior should be.
  The Gallery should retain its scroll position.


I've tried this only on 2.3.3, it may or may not exist on other platform versions. This is clearly a bug in Gallery's onLayout() (or the private layout()) function, as I can work around the issue with this code snippet in a class derived from Gallery:

  private long mLastScrollEvent;

  @Override
  protected void onLayout(boolean changed, int l, int t, int r, int b)
  {
    // XXX Hack alert!
    // Ignore layout calls if we've had a scroll event in the last 250 msec;
    // that'll ignore the per-second layout calls we get through BooPlayerView's
    // updating.
    long now = SystemClock.uptimeMillis();
    if (Math.abs(now - mLastScrollEvent) > 250) {
      super.onLayout(changed, l, t, r, b);
    }
  }

  @Override
  public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
  {
    mLastScrollEvent = SystemClock.uptimeMillis();
    return super.onScroll(e1, e2, distanceX, distanceY);
  }
Apr 15, 2011
#1 unwe...@gmail.com
Aand I should've removed most of that code comment. Nevermind :)
Sign in to add a comment

Powered by Google Project Hosting