Setting Padding1:14 with Ben Deitch
In this video we'll talk about how to add padding to our layout!
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 the mockups. 0:05 If we take another look, we see that there's some space between 0:07 each of our views and the edges of the screen. 0:11 We can change the amount of space by updating the padding property 0:14 of our relative layout. 0:17 Let's try to do this in XML. 0:20 Over on the Text tab, inside the relative layout element, 0:22 let's add a line below where we set the background. 0:27 Then type android:padding, and 0:31 set it equal to, in quotes, 50 DP. 0:35 Remember how we used SP as the units for tech size? 0:41 Well, DP is similar. 0:45 DP stands for density independent pixels. 0:47 Android devices can have all sorts of different screen resolutions. 0:50 And using density independent pixels helps us make sure that our app looks relatively 0:54 consistent across all those devices. 0:59 And now, we can see that our views have a little space offsetting 1:01 them from the edges of our relative layout, just like in the mockups. 1:04 In the next video, we'll see how to get rid of this bar at the top of the screen 1:09
You need to sign up for Treehouse in order to download course files.Sign up