Android webview 无法正确打开 Twitter 页面
Android webview doesn't open twitter page properly
我有一个 Android 应用程序可以在网络视图中打开一些页面。你可以看到
screenshot of the page。我看不到推文可以看到 header.
我已经尝试了所有 webview 设置,但它无法正常工作。
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new MyWebViewClient());
webview.setWebChromeClient(new MyWebChromeClient);
webview.getSettings().setDefaultTextEncodingName("utf-8");
webview.getSettings().setPluginState(PluginState.ON);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setDisplayZoomControls(false);
webview.getSettings().setUseWideViewPort(true);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setDomStorageEnabled(true);
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webview.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
[编辑]
我在下面的控制台上收到错误消息:
I/chromium: [INFO:CONSOLE(0)] "Refused to load the image 'https://www.google.com.tr/ads/ga-audiences?v=1&aip=1&t=sr&_r=4&tid=UA-30775-67&cid=1855674525.1467776671&jid=2048800659&_v=j44&z=267031279&ipr=y' because it violates the following Content Security Policy directive: "img-src 'self' 'unsafe-inline' blob: data: https://*.cdn.twitter.com https://ton.twitter.com https://*.twimg.com https://stats.g.doubleclick.net https://www.google.com https://www.google-analytics.com https://www.periscope.tv".
", source: https://mobile.twitter.com/home (0)
您必须像下面那样设置 layout_width 和 layout_height 属性。
android:layout_width="match_parent"
android:layout_height="match_parent"
我有一个 Android 应用程序可以在网络视图中打开一些页面。你可以看到
screenshot of the page。我看不到推文可以看到 header.
我已经尝试了所有 webview 设置,但它无法正常工作。
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new MyWebViewClient());
webview.setWebChromeClient(new MyWebChromeClient);
webview.getSettings().setDefaultTextEncodingName("utf-8");
webview.getSettings().setPluginState(PluginState.ON);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setDisplayZoomControls(false);
webview.getSettings().setUseWideViewPort(true);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setDomStorageEnabled(true);
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webview.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
[编辑] 我在下面的控制台上收到错误消息:
I/chromium: [INFO:CONSOLE(0)] "Refused to load the image 'https://www.google.com.tr/ads/ga-audiences?v=1&aip=1&t=sr&_r=4&tid=UA-30775-67&cid=1855674525.1467776671&jid=2048800659&_v=j44&z=267031279&ipr=y' because it violates the following Content Security Policy directive: "img-src 'self' 'unsafe-inline' blob: data: https://*.cdn.twitter.com https://ton.twitter.com https://*.twimg.com https://stats.g.doubleclick.net https://www.google.com https://www.google-analytics.com https://www.periscope.tv".
", source: https://mobile.twitter.com/home (0)
您必须像下面那样设置 layout_width 和 layout_height 属性。
android:layout_width="match_parent"
android:layout_height="match_parent"