实现类似HTML书籍的分页

时间:2011-02-10 09:16:58

标签: android html xml pagination epub

我在HTML book-like pagination找到了一个解决方案。我无法使用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.我把它放在错误的地方吗?任何帮助将不胜感激。

由于

1 个答案:

答案 0 :(得分:0)

我找到了这个解决方案,它对我有用。在此HTML book-like pagination上尝试Nacho L解决方案?