如何在相机上移动ImageView



有没有一种方法可以在相机上移动图像视图?我想能够用图像视图在上面拍照。

谢谢!!

是的,您所需要做的就是

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center" >
<!--Add your surface view to this frame layout  -->
<FrameLayout
    android:id="@+id/camera_preview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
</FrameLayout>
<ImageButton
    android:id="@+id/button_capture"
    android:src="@drawable/camera" />    

图像按钮或任何其他视图将显示在框架布局的顶部,其中存在显示相机框架的表面视图。对于移动图像,您可以执行类似的操作

void onTouch(Event event){
 params.leftMargin = (int)event.getX(); 
 params.topMargin = (int)event.getY();
 imagebutton.setLayoutParams(params);
}

实际上,听起来您想要制作合成图像。您可以使用另一个答案中描述的方法进行预览,但当您实际拍摄照片时,您需要将图像插入所拍摄的图片中。不要忘记拍摄的图片的大小可能会大于预览,因此您可能需要更改插入的图像大小/位置以匹配。

最新更新