How to calculate the text that can fit in a WebView without scrolling
I want to write an viewer that can display text justified, and it should display the amount of text that it can show on one screen without scrolling. Let say if I use WebView for justifying text, how to calculate the size of the text to be set in the view, so that the view can display it properly with that font without scrolling. I hope you got my question, like ebook readers disp开发者_Go百科lay text and then you have to swipe to load the next page, I want a similar functionality.
I dont think you can access the text in your HTML so you could try changing the font size with a javascript call.
- Calculate the font size in your Activity (or whereever you are calling your webview) either basing on your views size or the screen size or density.
- Send it to your webview via a JS call, like this
- The change the size in your HTML/JS.
精彩评论