A (175)

(Tuis.) #1

192 CHAPTER 6: Android Screen Design: Writing to the Display Using Activity and View


As you can see in the child tag pop-up helper (segment) shown in Figure 6 -2 3 , there are three layout
containers: FrameLayout, which we cover in Chapter 11, GridLayout, which we cover in Chapter 8, and
the LinearLayout, which we are covering in this chapter. The other 11 classes shown are UI widgets.


A slick way to calculate how many total class entries are shown in a helper dialog is to see how many
times the slider-bar height divides into the total height (in this case, about 5 times, or one-fifth slider-
bar height to total height ratio), and multiply that by the number of visible entries (in this case, 14),
giving you an estimate of 70 or more classes that are supported inside of a parent tag.


Double-click on the LinearLayout selection shown in Figure 6-23 and insert the empty


child tag into your activity_main.xml UI layout definition, so that we can start to
configure these nested UI layouts.

Reconfiguring Your LinearLayout Container


The first reconfiguration that we will want to do is to move the android:layout_margin=“12dip”
parameter from the parent tag over to the child tag that you just
added. This is to transfer the margin spacing for the UI elements that are underneath the


tag containing the text labels, which has now become a nested (child) LinearLayout.

The parent LinearLayout no longer needs any margin spacing, as it is now serving simply as a
horizontal layout “organizer” of child vertical LinearLayout containers, which will now be “carrying”
their own margin spacing configuration parameters. The movement of layout_margin from parent to
child tag is shown in Figure 6-24.


Figure 6-24. Configure a parent LinearLayout as horizontal and a child LinearLayout as vertical and transparent

Free download pdf