HarmonyOS 目前是否支持截长屏(长列表场景)?

目前的截长屏方案如下:

遍历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);
}
阅读 548
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进