gpt4 book ai didi

java - 在 android 中捕获完整的 webView

转载 作者:太空狗 更新时间:2023-10-29 14:50:25 24 4
gpt4 key购买 nike

我无法捕获完整的 WebView,我只捕获 Dashboard(Activity) 的可见内容。我的 WebView 超出了 Activity 范围。指导我如何捕获完整 View 。

webView.setWebViewClient(new WebViewClient() {

public void onPageFinished(WebView v, String url) {
webView.setDrawingCacheEnabled(true);
webView.buildDrawingCache();
Bitmap bmp = Bitmap.createBitmap(webView.getWidth(), webView.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bmp);
webView.draw(canvas);
imgView.setImageBitmap(bmp);
}
});

最佳答案

webView.setWebViewClient(new WebViewClient() {

public void onPageFinished(WebView v, String url) {
Picture picture = v.capturePicture();
Bitmap bmp = Bitmap.createBitmap(
picture.getWidth(), picture.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(b);
picture.draw(canvas);
imgView.setImageBitmap(bmp);
}

对不起,我没注意到

This method was deprecated in API level 19. Use onDraw(Canvas) to obtain a bitmap snapshot of the WebView, or saveWebArchive(String) to save the content to a file.

Gets a new picture that captures the current contents of this WebView. The picture is of the entire document being displayed, and is not limited to the area currently displayed by this WebView. Also, the picture is a static copy and is unaffected by later changes to the content being displayed.

关于java - 在 android 中捕获完整的 webView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35949402/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com