【发布时间】:2019-06-05 14:38:15
【问题描述】:
我遇到了 CameraX 屏幕旋转支持的问题。
纵向:
风景:
转换代码:
private void updateTransform() {
Log.d(TAG, "updateTransform: ");
Matrix matrix = new Matrix();
float centerX = cameraViewTextureV.getWidth() / 2f;
float centerY = cameraViewTextureV.getHeight() / 2f;
switch (cameraViewTextureV.getDisplay().getRotation()) {
case Surface.ROTATION_0:
rotation = 0;
break;
case Surface.ROTATION_90:
rotation = 90;
break;
case Surface.ROTATION_180:
rotation = 180;
break;
case Surface.ROTATION_270:
rotation = 270;
break;
default:
break;
}
matrix.postRotate((float) -rotation, centerX, centerY);
cameraViewTextureV.setTransform(matrix);
}
所以,正如您在图片中看到的那样,相机无法正确支持屏幕旋转...我在屏幕旋转时调用updateTransform 方法...
从 Android 开发者网站的 cameraX 官方指南中获取此代码。
将非常感谢任何修复建议。祝你有美好的一天!
【问题讨论】:
-
我在你的代码中发现了一个错误
-
@Roger,但不是我...
-
@Roger 你能回答我的问题吗?哪里出了问题?...
-
你能试试这个并更新我吗?
标签: android matrix android-jetpack android-camerax