解决方案可以用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%') }
解决方案
可以用stack布局,参考示例如下: