android - How to use the camera with images? -
i want make application contains image , background can use device camera. know how launch camera not how put image forward. example application:
https://play.google.com/store/apps/details?id=com.kat.police.photosuit.montage
anybody know tutorial explaining how or code?
i have searched can not find perhaps because english not good. in advance
please check example:
http://examples.javacodegeeks.com/android/core/ui/surfaceview/android-surfaceview-example/
and use 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 surfacecreated method need this:
camera.parameters parameters = camera.getparameters(); list<camera.size> previewsizes = parameters.getpreviewsizes(); // need choose appropriate previewsize app // example camera.size previewsize = previewsizes.get(0); camera.size previewsize = // .... select 1 of previewsizes here parameters.setpreviewsize(previewsize.width, previewsize.height); camera.setparameters(parameters); camera.startpreview();
Comments
Post a Comment