How to calculate text that can fit in a webview without scrolling

I want to write a viewer that can display text, and it should display the amount of text that it can display on one screen without scrolling. Say, if I use WebView to justify the text, how to calculate the size of the text that will be set in the view so that the view can correctly display it using this font without scrolling. I hope you have my question, as e-book readers display text, and then you have to swipe to load the next page, I need similar functionality.

+4
source share
1 answer

I don’t think you can access the text in your HTML so that you can try changing the font size with a javascript call.

  • Calculate the font size in your activity (or whatever you call your webview), either based on the size of the views, or the size of the screen, or the density .
  • Send it to your webview via JS call like this
  • Resize your HTML / JS.
+1
source

Source: https://habr.com/ru/post/1336756/


All Articles