实现HTML书籍式分页

4

我在HTML类书籍分页中找到了一种解决方案,但我无法在使用eclipse 3.6的Android上实现相同的效果。 我正在使用以下代码:

    mWebView.setWebViewClient(new WebViewClient() {     
     public void onPageFinished(WebView view, String url) {          
       // Column Count is just the number of 'screens' of text. Add one for partial 'screens'         
       int columnCount = Math.floor(view.getHeight() / view.getWidth())+1;          

       // Must be expressed as a percentage. If not set then the WebView will not stretch to give the desired effect.         
       int columnWidth = columnCount * 100;          
       String js = "var d = document.getElementsByTagName('body')[0];" +              "d.style.WebkitColumnCount=" + columnCount + ";" +              "d.style.WebkitColumnWidth='" + columnWidth + "%';";         

       mWebView.loadUrl("javascript:(function(){" + js + "})()");     
     } 
   });       

   mWebView.loadUrl("file:///android_asset/chapter.xml"); 

LogCat显示给我宽度和高度为0。我是否将其放错位置了?任何帮助都将不胜感激。

谢谢


2
欢迎来到stackoverflow,请使用选择代码并点击“{}”按钮,不要害怕使用一些换行和制表符:P - meo
1个回答

0

我找到了这个解决方案,它对我有用。尝试一下Nacho L在HTML类书籍分页上的解决方案?


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接