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