184 CHAPTER 6: Android Screen Design: Writing to the Display Using Activity and View
Note These android:layout_width and android:layout_height are the only required parameters to have
in both a ViewGroup (a parent tag) as well as a View (child tag) XML class reference. The reason these are
required in ViewGroup is because they’re required in View class inheritance scenarios, so essentially, every UI
element must define a layout_width and a layout_height constant, either wrap_content or match_parent,
which we’ll be looking at over the next few chapters.
Figure 6-16. Reconfiguring the first
Once you finish these edits, use the Run As ➤ Android Application work process, and the Android
application should look like what is shown in the middle part of the screen shot shown in Figure 6 -1 5.
As you can see, since we removed the android:padding parameters that pushed the UI content
away from the sides of the display screen, the UI design is now too close to (touching) the sides of
the display. We are going to use the android:layout_margin parameter to space the UI design away
from the sides of the screen next.
Although we could put these android:layout_margin parameters inside each of your
tags in order to achieve this end-result, it would be far more efficient to use the grouping feature of
the LinearLayout (ViewGroup) to space the entire design out by using a single parameter placed in
the LinearLayout parent tag.