Reputation: 167
I want to make an application that contains an image and the background you can use the device camera. I know how to launch the camera but not how put the image forward. An example would be this application:
https://play.google.com/store/apps/details?id=com.kat.police.photosuit.montage
Anybody know any tutorial explaining how to do it or some code?
I have searched but can not find perhaps because my English is not very good. Thanks in advance
Upvotes: 0
Views: 75
Reputation: 528
please check this example:
http://examples.javacodegeeks.com/android/core/ui/surfaceview/android-surfaceview-example/
and use this layout activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.javacodegeeks.androidsurfaceviewexample.AndroidSurfaceviewExample" >
<SurfaceView
android:id="@+id/surfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/police"
android:layout_above="@id/capture"/>
<LinearLayout
android:id="@+id/capture"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:background="@android:color/white"
android:gravity="center"
android:layout_alignParentBottom="true"
android:onClick="captureImage"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="Capture"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</RelativeLayout>
In your surfaceCreated method you need to do something like this:
Camera.Parameters parameters = camera.getParameters();
List<Camera.Size> previewSizes = parameters.getPreviewSizes();
// You need to choose the most appropriate previewSize for your app
// Example Camera.Size previewSize = previewSizes.get(0);
Camera.Size previewSize = // .... select one of previewSizes here
parameters.setPreviewSize(previewSize.width, previewSize.height);
camera.setParameters(parameters);
camera.startPreview();
Upvotes: 1
Reputation: 606
In my opinion your solution should not be overlapping images. I think that what your are looking for is more complex. You should have both images and then program an algorithm to mix them up and show just one image on your imageView.
Upvotes: 0