Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/201.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在相机上移动ImageView?_Android_Android Camera_Android Imageview - Fatal编程技术网

Android 如何在相机上移动ImageView?

Android 如何在相机上移动ImageView?,android,android-camera,android-imageview,Android,Android Camera,Android Imageview,有没有一种方法可以使imageview在相机上移动?我希望能够在顶部使用imageview拍摄照片 谢谢 是的,你所需要做的就是 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="cente

有没有一种方法可以使imageview在相机上移动?我希望能够在顶部使用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" />    

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

谢谢!但是如何更改图片的大小和位置以匹配预览?如果您知道预览的大小和最终图片的大小,您可以计算一个标量,然后将图像大小和位置乘以该标量。。例如,双刻度=最终图片宽度/预览宽度;previewOverlayWidth=最终图片覆盖宽度*比例;previewOverlayXPos=finalPictureOverlayXPos*scale。。然后对高度执行同样的操作,就可以得到预览的缩放覆盖位置和大小。。
void onTouch(Event event){

 params.leftMargin = (int)event.getX(); 
 params.topMargin = (int)event.getY();
 imagebutton.setLayoutParams(params);
}