Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Including One Layout in Another0:57 with Michael Lustig
The 'include' tag is a powerful trick used in Android layouts to decrease duplicated code. Let's see how to use them in our music application. Toward the end of the video, I 'll issue you a challenge to create your first style on your own.
Before we move on, I wanted to point out a cool feature of Android
layouts that I'm using in this app.
If you look at the activitysongplayback.xml file,
you'll notice that I have an interesting looking tag called include.
Although it isn't something that directly relates to styles and
themes, I wanted to share this cool trick as it's used a couple of times in the app.
And it's a great way to isolate layouts that are semantically similar.
To utilize the include tag, you simply have to declare your layout file in
one file, and you use the include tag in another layout that you want to use it in.
Then, specify the layout attribute with the name of the file your layout you'd
like to include was created in.
Now that you've got another cool Android trick under your belt,
I'm going to challenge you to extract another couple of styles for this app.
Try and see if you can create a style for
the song's playback time and the song's duration.
Then, if you want to go above and beyond,
try styling the album artwork with the rounded corners in the playback activity.
Come back when you're ready for my solution.
You need to sign up for Treehouse in order to download course files.Sign up