Taking a Photograph

In this case, you simply request photos from the default camera app that users have set up on the device. Here’s how.

1. Open the activity_timer XML layout file. Above the existing TextView, add a new LinearLayout. In this LinearLayout, set the android:layout_width to 160dp, set the android:layout_height to wrap_content, and give it an android:layout_marginBottom of 8dp. Set both android:layout_alignParentTop and android:layout_centerHorizontal to true to align and center the button at the top of the view (see Listing 8.1).

Listing 8.1 Setting the Layout and Aligning and Centering the Button

<LinearLayout    android:layout_width="160dp"     android:layout_height="wrap_content"     android:layout_alignParentTop ...

Get Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.