3

我使用 GlSurfaceView 使用旧相机 api 和相机 2 api。当我在旧 api 中获得必要的纵横比时,我使用 Camera.Parameters

camParams.setPreviewSize(previewW, previewH);
       if(isPictureSizeSupported(camParams, newSize)) {
           camParams.setPictureSize(newSize.getWidth(), newSize.getHeight());
       }

如果它不会被调用,则预览会被拉伸

问:如何在camera 2 api中获得这样的效果?

4

1 回答 1

0

我迁移到SurfaceViewsetFixedSize()SurfaceHolder. 正如文档所说:

绘制到 SurfaceView: 创建 SurfaceView 的 Surface 后,使用 setFixedSize(int, int) 将 Surface 的大小设置为 getOutputSizes(SurfaceHolder.class) 返回的大小之一,然后通过调用 getSurface() 获取 Surface

于 2016-07-01T14:50:13.317 回答