Chapter 10. Fragments for Larger Interfaces: Different Size, Different Interface
So far we’ve only run our apps on devices with a small screen.
But what if your users have tablets? In this chapter you’ll see how to create flexible user interfaces by making your app look and behave differently depending on the device it’s running on. We’ll show you how to control the behavior of your app when you press the Back button by introducing you to the back stack and fragment transactions. Finally, you’ll find out how to save and restore the state of your fragment.
The Workout app looks the same on a phone and a tablet
In the previous chapter, we created a version of the Workout app designed to work on a phone.
As a reminder, when the app launches, it displays MainActivity
. This contains a fragment, WorkoutListFragment
, that displays a list of workouts. When the user clicks on one of the workouts, DetailActivity
starts, and displays details of the workout in its fragment, WorkoutDetailFragment
.
When we run the app on a tablet, the app works in exactly the same way. As the screen size is larger, however, there’s lots of empty space in the user interface that we could make better use of.
Designing for ...
Get Head First Android Development, 2nd Edition 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.