Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
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
0:00
layouts that I'm using in this app.
0:03
If you look at
the activitysongplayback.xml file,
0:04
you'll notice that I have an interesting
looking tag called include.
0:08
Although it isn't something that
directly relates to styles and
0:11
themes, I wanted to share this cool trick
as it's used a couple of times in the app.
0:13
And it's a great way to isolate
layouts that are semantically similar.
0:17
To utilize the include tag, you simply
have to declare your layout file in
0:20
one file, and you use the include tag in
another layout that you want to use it in.
0:24
Then, specify the layout attribute with
the name of the file your layout you'd
0:28
like to include was created in.
0:32
Now that you've got another cool
Android trick under your belt,
0:38
I'm going to challenge you to extract
another couple of styles for this app.
0:40
Try and see if you can create a style for
0:44
the song's playback time and
the song's duration.
0:46
Then, if you want to go above and beyond,
0:49
try styling the album artwork with the
rounded corners in the playback activity.
0:51
Come back when you're ready for
my solution.
0:55
You need to sign up for Treehouse in order to download course files.
Sign up