Android Recipes: A Problem-Solution Approach by Dave Smith Jeff Friesen

Android Recipes: A Problem-Solution Approach by Dave Smith Jeff Friesen

Author:Dave Smith, Jeff Friesen
Language: eng
Format: epub, pdf
Publisher: Apress®
Published: 2012-12-12T16:00:00+00:00


Photo Overlay

We can now add on to the previous example any controls or views that are appropriate to display on top of the camera preview. Let’s modify the preview to include a Cancel button and a Snap Photo button. See Listings 4-18 and 4-19.

Listing 4-18. res/layout/main.xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent">

<SurfaceView

android:id="@+id/preview"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

/>

<RelativeLayout

android:layout_width="fill_parent"

android:layout_height="100dip"

android:layout_alignParentBottom="true"

android:gravity="center_vertical"

android:background="#A000">

<Button

android:layout_width="100dip"

android:layout_height="wrap_content"

android:text="Cancel"

android:onClick="onCancelClick"

/>

<Button

android:layout_width="100dip"

android:layout_height="wrap_content"

android:layout_alignParentRight="true"

android:text="Snap Photo"

android:onClick="onSnapClick"

/>

</RelativeLayout>

</RelativeLayout>

Listing 4-19. Activity with Photo Controls Added

public class PreviewActivity extends Activity implements

SurfaceHolder.Callback, Camera.ShutterCallback, Camera.PictureCallback {



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.