Android Programming: The Big Nerd Ranch Guide, 5th Edition
by Bryan Sills, Brian Gardner, Kristin Marsicano, Chris Stewart
For the More Curious: Margins vs Padding
In both GeoQuiz and CriminalIntent, you have given views margin and padding attributes. Beginning developers sometimes get confused about these two. Now that you understand what a layout parameter is, the difference is easier to explain.
Margin attributes are layout parameters. They determine the distance between views. Because a view can only know about itself, margins must be the responsibility of the view’s parent.
Padding, on the other hand, is not a layout parameter.
The android:padding attribute tells a view how much bigger than its contents it should draw itself.
For example, say you wanted the date button to be spectacularly large without changing its text size (Figure 11.36 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access