PhotoView zoom resets when system UI visibility changes

Created on 24 Aug 2016  路  9Comments  路  Source: Baseflow/PhotoView

It seems to be because setFrame() is called when the system UI visibility changes and that calls update() regardless of whether the frame actually changed. (In my case, the system UI is stable so it doesn't.)

Possible fixes:

  • Make setFrame() not call update() if the bounds don't change. This would only work if the system UI was stable. Or:
  • Make update() retain the same relative scale when possible.

If needed, I could submit a pull-request to implement the first option, however I don't know enough about the internals to do the second.

Thanks.

Most helpful comment

I already fixed it locally by making setFrame only call update if the changed variable is true. I'm hoping it can be fixed in the official implementation so I don't have to keep a copy of PhotoView around in my source.

All 9 comments

i try not override setFrame in your PhotoView.java , it works

 //  @Override
//    protected boolean setFrame(int l, int t, int r, int b) {
//        boolean changed = super.setFrame(l, t, r, b);
//        if (null != mAttacher) {
//            mAttacher.update();
//        }
//        return changed;
//    }

or

   @Override
     protected boolean setFrame(int l, int t, int r, int b) {
         boolean changed = super.setFrame(l, t, r, b);
         if (changed && null != mAttacher) {
            mAttacher.update();
         }
        return changed;
     }

I already fixed it locally by making setFrame only call update if the changed variable is true. I'm hoping it can be fixed in the official implementation so I don't have to keep a copy of PhotoView around in my source.

Did this ever get fixed?

if (changed && null != mAttacher) {
mAttacher.update();
}

this code have issue when use sharedElement

i find a good solution when use sharedElement

@Override
public Matrix getImageMatrix() {

    mAttacher.update();

    return mAttacher.getImageMatrix();
}

if you have a same problem you can try it

Also experienced this bug. I'm using the Android Databinding library and if ever I update any TextView's text via databinding the PhotoView also seems to "reset". Same behavior when I tried to update a FloatingActionButton's visibility (also via databinding) to and from GONE, but it seems to and from INVISIBLE doesn't trigger a setFrame(). Followed @FaultException and I reluctantly have a local copy of PhotoView. Hoping it can be fixed in the official repo!

@hyne-shan What issue does that cause with shared elements?

@FaultException The animation will shake

This is fixed now

Was this page helpful?
0 / 5 - 0 ratings