开发者

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.

  1. 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.
  2. Send it to your webview via a JS call, like this
  3. The change the size in your HTML/JS.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜