【发布时间】:2013-08-08 06:24:39
【问题描述】:
有没有办法让图像视图可以在相机上移动?我希望能够在顶部的 imageview 上拍照。
谢谢!!
【问题讨论】:
标签: android android-camera android-imageview
有没有办法让图像视图可以在相机上移动?我希望能够在顶部的 imageview 上拍照。
谢谢!!
【问题讨论】:
标签: android android-camera android-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);
}
【讨论】:
实际上,您似乎想要制作合成图像。您可以使用其他答案中描述的方法进行预览,但是当您实际拍摄照片时,您需要将图像插入到拍摄的照片中。不要忘记拍摄的图片尺寸可能会大于预览图,因此您可能需要更改插入的图片尺寸/位置以匹配。
【讨论】: