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

Scrollbars #29

Closed
markusressel opened this issue Jun 5, 2018 · 5 comments
Closed

Scrollbars #29

markusressel opened this issue Jun 5, 2018 · 5 comments

Comments

@markusressel
Copy link
Collaborator

markusressel commented Jun 5, 2018

Hey, awesome library :)

I want to use this to build a Text Editor and want to add scrollbars for both x and y axis.
Is there some kind of listener/callback API that I missed to intercept changes in the current positioning of the ZoomLayout? If so I would be able to implement scrollbars myself and update them even when "flinging" the position.

It would also be cool to have something like this (scrollbars) built in - although it might be out of scope for this library.

Thx for the great work.

@natario1
Copy link
Owner

natario1 commented Jun 6, 2018

Thanks!

You should override onUpdate(). And get X and Y from the matrix (or ask the engine). Take a look at the ZoomLayout source code, it's pretty simple.

I think it would be in scope for both ZoomLayout and ZoomImageView so if you work this out feel free to submit a PR. Note, here we would want to let Android draw them using the view callbacks, not draw 'custom' scrollbars onDraw

@markusressel
Copy link
Collaborator Author

I'm not sure I can follow you on "let Android draw them using the view callbacks". As far as I can tell neither FrameLayout nor ImageView have built in support for scrollbars? So the only way to show scrollbars would be to add them by hand and update their position using the onUpdate() method.

Do you simply mean to use "Views" (added to the FrameLayout) which android draws instead of manually drawing rectangles in onDraw?

@natario1
Copy link
Owner

natario1 commented Jun 6, 2018

It's been a long time but as far as I remember, View or ViewGroup have builtin support for drawing scrollbars.

But the view must implement a few methods, like computeVerticalScrollRange or something like that, and then the base class will draw scrollbars based on the android:scrollbars attribute.

So if I remember correctly, you should just implement this 2? 4? methods by using the engine values. A good starting point might be the NestedScrollView source code from Google.

@natario1
Copy link
Owner

natario1 commented Jun 6, 2018

Oh and you should call awakenScrollBars when change is detected. Basically on all updates.

@markusressel
Copy link
Collaborator Author

Thx for the help, now I understand 😊

I will look into implementing this somewhere around (hopefully) this or next week.

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

No branches or pull requests

2 participants