Developing the UI with Fragments
This chapter covers fragments and the fragment lifecycle. It demonstrates how to use them to build efficient and dynamic layouts that respond to different screen sizes and configurations and allow you to divide your UI into different sections. By the end of this chapter, you will be able to create static and dynamic fragments, pass data to and from fragments and activities, and use the Jetpack Navigation
component to detail how fragments fit together.
In the previous chapter, we explored the Android activity lifecycle and looked into how it is used in apps to navigate between screens. We also analyzed various types of launch modes, which defined how transitioning between screens happened. In this chapter, you’ll explore fragments. A fragment is a section, portion, or, as the name implies, fragment of an Android activity.
Throughout the chapter, you’ll learn how to use fragments, see how they can exist in more than one activity, and...