Advertisement
English transcript
fontFamily is the attribute that you would use to set the font for
a TextView.
Since we want the actual font to be Sans Serif Light,
sans-serif-light is the value that we use for the attribute fontFamily.
To make that a little bit more clear, let me show you in Android Studio.
Okay, I'm back here in my lovely activity_main.xml and
let's add some more attributes.
I'm going to start with the Happy Birthday, Ben TextView, and
the attribute I am adding is android:fontFamily.
Okay, and the fontFamily that I wanted to use if you remember from the last
slide is sans, that's with an s, -serif-light.
And as always, it's nestled between two quotation marks.
Now, this is a little bit hard to see, but
the preview view has updated to show us the thinner, San Serif Light font.
You can see it best if you click on something that's not the TextView, and
sort of compare these two look like, since this is the old font and
this is the new font.
A couple of things to notice, or problems that you might have run into.
These things here are dashes, they're not underscores.
So make sure you get that absolutely right.
And make sure you spelled sans-serif-light completely correct.
For example,
the computer won't recognize sans_serif_light with underscores.
You can see here it has reverted back to the old font.
Also note, that when you hover over the text, you might get this message.
Attribute fontFamily is only used in API level 16 and higher, current min is 15.
If you remember back to when we made the project, we set the minimum SDK to 15,
or Ice Cream Sandwich.
What this is telling us is, to use this attribute, you need one higher version.
This isn't a huge deal but
basically what it means is that on older phones you're going to see the old
chunkier font and on newer phones you'll actually see the Sans Serif Light font.
Okay, so I'm going to continue on and add the attribute to my other TextView.
Let's scroll down.
android:fontFamily.
Okay, and now on the preview screen everything looks correct, but
always run it on your phone.
I'm going to hit the green run button.
I'm going to wait a million years.
I'm going to hit the phone, going to hit OK.
All right, and when you load it up on your phone, you should be able
to see that you have a little bit of a thinner Sans Serif Light font.
Excellent work, two down, three more to go.
a TextView.
Since we want the actual font to be Sans Serif Light,
sans-serif-light is the value that we use for the attribute fontFamily.
To make that a little bit more clear, let me show you in Android Studio.
Okay, I'm back here in my lovely activity_main.xml and
let's add some more attributes.
I'm going to start with the Happy Birthday, Ben TextView, and
the attribute I am adding is android:fontFamily.
Okay, and the fontFamily that I wanted to use if you remember from the last
slide is sans, that's with an s, -serif-light.
And as always, it's nestled between two quotation marks.
Now, this is a little bit hard to see, but
the preview view has updated to show us the thinner, San Serif Light font.
You can see it best if you click on something that's not the TextView, and
sort of compare these two look like, since this is the old font and
this is the new font.
A couple of things to notice, or problems that you might have run into.
These things here are dashes, they're not underscores.
So make sure you get that absolutely right.
And make sure you spelled sans-serif-light completely correct.
For example,
the computer won't recognize sans_serif_light with underscores.
You can see here it has reverted back to the old font.
Also note, that when you hover over the text, you might get this message.
Attribute fontFamily is only used in API level 16 and higher, current min is 15.
If you remember back to when we made the project, we set the minimum SDK to 15,
or Ice Cream Sandwich.
What this is telling us is, to use this attribute, you need one higher version.
This isn't a huge deal but
basically what it means is that on older phones you're going to see the old
chunkier font and on newer phones you'll actually see the Sans Serif Light font.
Okay, so I'm going to continue on and add the attribute to my other TextView.
Let's scroll down.
android:fontFamily.
Okay, and now on the preview screen everything looks correct, but
always run it on your phone.
I'm going to hit the green run button.
I'm going to wait a million years.
I'm going to hit the phone, going to hit OK.
All right, and when you load it up on your phone, you should be able
to see that you have a little bit of a thinner Sans Serif Light font.
Excellent work, two down, three more to go.