Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't pan to full child view height when zoomed in #123

Closed
bizzyman opened this issue Aug 13, 2018 · 7 comments
Closed

Can't pan to full child view height when zoomed in #123

bizzyman opened this issue Aug 13, 2018 · 7 comments
Labels

Comments

@bizzyman
Copy link

I have a layout structure as such:

<ConstraintLayout/>
    <ScrollView/>
        <GestureFrameLayout/>
            <ConstraintLayout/>   <-- has an image as background around 2500px

When I try to zoom in after moving down the scrollview (let's say to the bottom of the child element of scrollview), then when I try to pan upwards to the top of the image that is the background of my ConstraintLayout (whilst still zoomed in), I am restricted to only going upwards to a fraction of the height.

Here is an image trying to explain the issue:

zoom

@alexvasilkov
Copy link
Owner

Nesting scrolling content is usually a not very good idea. In this particular case it seems like ScrollView is scrolled down and you can only see a part of GestureFrameLayout. So when you are panning inside GestureFrameLayout it operates within the area shown by ScrollView, meaning that it will not be possible to see its top part without scrolling ScrollView itself.

I guess you expect that when GestureFrameLayout reaches its top side it will automatically start scrolling its parent, but it is not supposed to do so.

Can you please share your use case, why do you need to nest GestureFrameLayout inside ScrollView?

@bizzyman
Copy link
Author

Sure, I have a large image as a background with text that the user needs to read (not the one in the gif), and there are several EditText's along the scrollview (actually inside the bottom ConstraintLayout).

I tried removing the Scrollview but then have 2 problems:

  1. I need to be able to scroll (or pan?) the GestureFrameLayout programmatically, this is what I am doing with the scrollview currently
  2. When I try and use an EditText at the bottom of the GestureFrameLayout the keyboard obstructs the view and there is no way to scroll down to see the EditText.

@alexvasilkov
Copy link
Owner

I think you can assume that GestureFrameLayout is similar to Map view. Placing map view inside ScrollView will not work well, and same for GestureFrameLayout.

You may consider to add a separate screen where user will have an option to scale and pan the layout or place it in a fixed location on the screen (e.g. on the bottom).

@bizzyman
Copy link
Author

Is there any way to pan programmatically GestureFrameLayout?

@alexvasilkov
Copy link
Owner

Yes, this can be done by manually controlling its state (getController.getState() and then getController().updateState() to apply state changes).

@bizzyman
Copy link
Author

Thank you! Sorry, one last question, is there any way to smoothly animate from one state to another? A bit like scrollView.smoothScrollTo?

@bizzyman
Copy link
Author

Ok, I have figured it out, I create a new State instance and pass to getController().animateStateTo(state).
Many thanks for your help, I will close this issue now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants