我正在尝试将 webview 转换为 android 中的位图。但是 webview 的高度和宽度总是为零?
这是代码:
String unescaped = StringEscapeUtils.unescapeHtml4(b
.getString("issueDescription"));
try {
customHtml = new String(unescaped.getBytes("ISO-8859-1"), "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
customHtml = "<link rel='Stylesheet' href='index.css'/>" + customHtml;
webView = (WebView) findViewById(R.id.issueDescription);
webView.loadDataWithBaseURL("file:///android_asset/", customHtml, null,
"utf-8", null);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
int mWidth = view.getWidth();
int mHeight = view.getHeight();
Picture bmp1 = view.capturePicture();
PictureDrawable pd1 = new PictureDrawable(bmp1);
Bitmap bitmap1 = Bitmap.createBitmap(pd1.getIntrinsicWidth(),
pd1.getIntrinsicHeight(), Config.ARGB_8888);
}
});