O'Reilly logo

Android Programming for Beginners by John Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Displaying a photo from the database

Let's start by building a simple layout that our soon-to-be-built fragment can use.

Preparing the View layout

Create a new layout by right-clicking on the layout folder and choosing New | Resource layout file, naming it fragment_view, and left-clicking OK.

This image is what we are aiming for, but there is also an unseen ImageView covering the entire layout:

Preparing the View layout

To achieve this layout, add the following XML code to the fragment_view.xml file. I have highlighted a few points worth noting that we will discuss:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required