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
In this video we'll talk about how to add padding to our layout!
Related Links
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
We're almost done with our layout.
0:00
The last thing we need to do is
set the padding around our views
0:02
to match our markups.
0:05
If we take another look,
we see that there's some space between
0:06
each of our views and
the edges of the screen.
0:10
We can change the amount of space
by updating the padding property
0:13
of a relative layout.
0:17
Let's try to do this in XML.
0:18
Over on the text tab inside
the relative layout element,
0:20
add a line below where
we set the background.
0:25
Then type android:padding and
0:30
set it equal to, in quotes, 50dp.
0:34
Remember how we used sp as the units for
text size?
0:40
Well, dp is similar.
0:45
Dp stands for density independent pixels.
0:46
Android devices can have all sorts
of different screen resolutions.
0:50
And using density independent pixels
helps us make sure our app looks
0:53
relatively consistent
across all those devices.
0:57
And now we can see that our views
have a little space off setting them
1:01
from the edges of our relative layout,
just like in the mock ups.
1:04
In the next video, we'll see how to get
rid of this bar at the top of the screen.
1:08
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up