1 个回答

解决方案

可以用stack布局,参考示例如下:

Stack() {
  XComponent({
    id: '',
    type: 'surface',
    libraryname: '',
    controller: this.mXComponentController
  })
    .onLoad(() => {
      // 设置Surface宽高(1920*1080),预览尺寸设置参考前面 previewProfilesArray 获取的当前设备所支持的预览分辨率大小去设置
      // 预览流与录像输出流的分辨率的宽高比要保持一致
      this.mXComponentController.setXComponentSurfaceRect({
        offsetX: 0,
        offsetY: 0,
        surfaceWidth: this.screenWidth,
        surfaceHeight: this.screenWidth
      });
      // 获取Surface ID
      this.surfaceId = this.mXComponentController.getXComponentSurfaceId();
      setTimeout(async () => {
        if (this.SceneMode == 0) {
          await this.prepareCamera(this.ca);
        } else {
          await this.initVideoCamera(this.ca);
        }
      }, 500);
    })
    .width('100%')
    .height(this.imageType == 0 ? px2vp(this.screenWidth) : px2vp(this.screenWidth * 1920.0 / 1080.0))
  //蒙板图片
  Image($r('app.media.background'))
    .width('100%')
    .height('100%')
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进