How to zoom to a specific rectangle (SVG rect) inside local HTML page in Android WebView

Viewed 17

Given: A local HTML page (in assets) that contains an SVG and a Rect of certain sizes in it. The page is loaded when the application starts in the WebView.

How to zoom in to this Rect dynamically while the application is running so that it occupies the entire visible area of the screen using WebView.zoomBy or JS?

P.S. I tried to calculate the ratio of zoom to the areas of rectangles, manipulations with JS and WebView, but maybe I was thinking wrong.

Thank you!

Illustration:

Illustration

1 Answers

Found a solution by calculating the required scale depending on the aspect ratio and display dimensions and the zoom factor for webView.zoomBy().

Related