目前的截长屏方案如下:
遍历scrollview的child进行draw从而达到截长屏的目前,HarmonyOS 上如何遍历scrollview的child并进行绘制,目前是否有类似能力。
final Point resolution = new Point(width, height);
Bitmap bitmap = getBitmapForScreenshot(width, height);
Canvas canvas = new Canvas(bitmap);
Drawable bgDrawable = view.getBackground();
if (bgDrawable != null) {
bgDrawable.draw(canvas);
} else {
canvas.drawColor(Color.WHITE);
}
if (view instanceof ScrollView) {
int childCount = ((ScrollView) view).getChildCount();
for (int i = 0; i < childCount; i++) {
((ScrollView) view).getChildAt(i).draw(canvas);
}
} else {
view.draw(canvas);
}
当前有组件截图功能,但scroll没有长截图能力,componentSnapshot.get(‘scroll’)无法长截图。
针对web网页的长截屏,可以参考以下方法:
https://developer.huawei.com/consumer/cn/forum/topic/0204148902474871342?fid=0109140870620153026