我正在开发一个camera2应用程序.在Nexus 5和Nexus 4上一切正常,但在LG G2预览视频是拉伸的(仅适用于后置摄像头,前置摄像头一切都很好).我正在设置SurfaceTexture:
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
float ratioSurface = width > height ? (float) width / height : (float) height / width;
float ratioPreview = (float) mRatioWidth / mRatioHeight;
int scaledHeight = height;
int scaledWidth = width;
if (ratioPreview > ratioSurface) {
scaledHeight = (int) (((float) mRatioWidth / mRatioHeight) * width);
} else if (ratioPreview < ratioSurface) {
scaledWidth = (int) (height / ((float) …Run Code Online (Sandbox Code Playgroud)