如何在 Android 中获取位图混合( native + html)的应用程序的当前 View ?
该方法只能给出原生元素:
public static Bitmap getScreenShot(View view) {
View screenView = view.getRootView();
screenView.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(screenView.getDrawingCache());
screenView.setDrawingCacheEnabled(false);
return bitmap;
}
// View to BitMap
Bitmap b = getScreenShot(getWindow().getDecorView().findViewById(android.R.id.content));
我们如何将混合元素( native View + 当前显示的 HTML 内容)转换为位图?
最佳答案
该代码就足够了。 HTML 内容位于 native View - WebView 中。将 WebView 传递到该代码中,您将获得 html 的位图。请注意,这里很容易遇到 OOM 问题 - HTML 内容的像素通常非常大。
关于java - 如何将混合应用程序的当前 View 转换为位图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41500639/