Michael Eilers Smith
Michael Eilers Smith

Reputation: 8618

How to move ImageView over camera?

Is there a way to have an imageview that can be moved over the camera? I want to be able to take a picture with the imageview on top.

Thanks!!

Upvotes: 0

Views: 589

Answers (2)

C B J
C B J

Reputation: 1868

Actually it sounds like you are wanting to make composite images. You can use the method described in the other answer for the preview, but when you actually take the photograph, you will need to insert the image into the picture taken. Dont forget the size of the picture taken probably will be larger than the preview, so you may need to change the inserted image size/position to match.

Upvotes: 1

mchouhan
mchouhan

Reputation: 1873

yes, all you need to do is

<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" />    

the imagebutton or any other view will be shown on the top of the framelayout where your surface view displaying camera frame exists.For moving the image you can do something like

void onTouch(Event event){

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

Upvotes: 1

Related Questions