将targetSdkVersion更改为29后,Web视图不起作用
我已经尝试过
WebView summaryContentInstagramWebView = (WebView) summaryContentInstagramLinearLayout.findViewById(R.id.contentInstagramWebView);
summaryContentInstagramWebView.getSettings().setJavaScriptEnabled(true);
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
float dpHeight = displayMetrics.heightPixels / displayMetrics.density;
float dpWidth = displayMetrics.widthPixels / displayMetrics.density;
float iframeWidth = (dpWidth / 360) * 300;
float iframeHeight = (dpHeight / 640) * 400;
String html = "<html><body><iframe style=\"border: 1px solid #EEEEEE;\" type=\"text/html\" width=\"" + iframeWidth + "\" height=\"" + iframeHeight + "\" scrolling=\"no\" src=\"" + summaryJson.getString("url") + "\" frameborder=\"0\" allowFullScreen></body></html>";
String encodedHtml = Base64.encodeToString(html.getBytes(), Base64.NO_PADDING);
summaryContentInstagramWebView.loadData(encodedHtml, "text/html", "utf-8");
summaryContentInstagramWebView.setWebViewClient(new WebViewClient());
但是不起作用。 请帮忙。