我一直在使用
camera2 api demo from google,不幸的是,示例应用程序构建为在屏幕高度的大约70%处显示纹理视图预览,在环顾四周之后我能够确定这是由AutoFitTextureView覆盖onMeasure()方法引起的如下所示:
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
if (0 == mRatioWidth || 0 == mRatioHeight) {
setMeasuredDimension(width, height);
} else {
if (width < height * mRatioWidth / mRatioHeight) {
setMeasuredDimension(width, width * mRatioHeight / mRatioWidth);
} else {
setMeasuredDimension(height * mRatioWidth / mRatioHeight, height);
}
}
}
我试图通过在setMeasuredDimension(宽度,高度)中设置正确的高度和宽度来纠正这个问题;这解决了高度问题,并从纹理视图中给我一个全屏预览,但是宽高比在每个设备上完全断开并扭曲,解决这个问题的标准方法是什么?我看到很多应用程序在游戏商店找到了解决这个问题的方法,但还没能找到解决方案,任何帮助都会有很长的路要走,谢谢.
博客作者在使用Google的Camera2 API Demo时遇到预览显示在屏幕高度约70%的问题,原因是AutoFitTextureView的onMeasure()方法导致。尝试修改setMeasuredDimension()后,虽然解决了高度问题,但导致了预览的宽高比在不同设备上扭曲。寻求标准方法解决全屏预览与保持正确宽高比的冲突,希望获得帮助。

5729

被折叠的 条评论
为什么被折叠?



