2014-11-17 79 views
2

我正尝试在我的WebView上加载Time.comWebView将不会滚动某些网页

加载本身工作正常,但加载的页面不滚动。

  1. 它具有内置的浏览器,Chrome浏览器
  2. 如果我使用其他网址(例如:http://www.google.com/)效果很好,它工作正常。

我认为问题出现在网页(html)中,但我找不出什么问题。

下面是代码,但没有什么特别之处。

MainActivity.java

package com.yooiistudios.webviewperformance; 

import android.os.Bundle; 
import android.support.v7.app.ActionBarActivity; 
import android.view.Menu; 
import android.webkit.WebView; 
import android.webkit.WebViewClient; 


public class MainActivity extends ActionBarActivity { 

    private WebView mWebView; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     mWebView = (WebView)findViewById(R.id.webView); 
     mWebView.setWebViewClient(new NewsWebViewClient()); 
     mWebView.loadUrl("http://www.time.com/"); 
    } 

    private class NewsWebViewClient extends WebViewClient { 

     @Override 
     public boolean shouldOverrideUrlLoading(WebView view, String url) { 
      view.loadUrl(url); 
      return true; 
     } 
    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.menu_main, menu); 
     return true; 
    } 
} 

activity_main.xml中

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:tools="http://schemas.android.com/tools" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:paddingLeft="@dimen/activity_horizontal_margin" 
       android:paddingRight="@dimen/activity_horizontal_margin" 
       android:paddingTop="@dimen/activity_vertical_margin" 
       android:paddingBottom="@dimen/activity_vertical_margin" 
       tools:context=".MainActivity"> 

    <WebView 
     android:id="@+id/webView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 

</RelativeLayout> 
+0

我在这里有同样的问题。 –

回答

0

经过一番研究,我发现HTML5WebView适合我的情况。

另外我有一个问题,一些视频在网页上不会播放默认的android webview,并且HTML5WebView也解决了这个问题。

源代码它自己有点肮脏和混乱,它工作正常。

无论如何,我在这里留下链接。希望这可以帮助有同样问题的人。

链接:https://code.google.com/p/html5webview/source/browse/trunk/HTML5WebView/src/org/itri/html5webview/HTML5WebView.java