【发布时间】:2018-05-09 15:43:46
【问题描述】:
这就是我想要做的。
我有一个相机视图,用户可以执行一些过程(缩放、移动和旋转)
当用户捕获图像时,我需要将其与相机视图上的应用程序放在相机框的相同位置
我这样做如下
mCameraView 是相机视图,mCaptureImage 是预览图像
float x = mCameraView.getX();
float y = mCameraView.getY();
mCaptureImage.setX(x);
mCaptureImage.setY(y);
float angel = mCameraView.getRotation();
mCaptureImage.setRotation(angel);
float scaleX, scaleY;
scaleX = mCameraView.getScaleX();
scaleY = mCameraView.getScaleY();
mCaptureImage.setScaleX(scaleX);
mCaptureImage.setScaleY(scaleY);
如果用户不旋转盒子,一切都很好
但是,如果用户旋转盒子,我会得到错误的 x,y 值,我不知道为什么会发生这种情况,并且图像会跳转到未指定的位置
我做了调试,发现旋转视图时x,y值发生了变化
这是XML的代码
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/selfie_move_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<com.otaliastudios.cameraview.CameraView
android:id="@+id/selfie_camera_view"
android:layout_width="300dp"
android:layout_height="200dp"
android:layout_gravity="center_vertical|center_horizontal"
android:visibility="gone"
app:cameraCropOutput="true"
app:cameraPlaySounds="false" />
<ImageView
android:id="@+id/selfie_capture_image"
android:layout_width="300dp"
android:layout_height="200dp"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:visibility="gone" />
</FrameLayout>
Exmaple about rotation view
谁能帮我解决这个问题?
【问题讨论】:
-
你明白这个问题了吗?视图的旋转不适用于活动
-
你找到解决方案了吗?
-
很遗憾,没有:(
标签: android android-studio android-camera