A (175)

(Tuis.) #1
CHAPTER 6: Android Screen Design: Writing to the Display Using Activity and View 195

The reason you can’t see the second is because you have all of your
structure android:layout_width and android:layout_height parameters set to use the match_parent
constant.


What this match_parent constant tells Android to do for both the width (X axis) and height
(Y axis) dimensions of the layout container is to expand the layout container to fill the UI layout
container “above” it in the display hierarchy. For the first parent , this tells Android
to fill the device display screen, which is what we want, and you can see by the background
image filling the screen (once we removed the margins) that this is working as desired. The first
nested is therefore also filling the screen, leaving no room for the second nested


to display its contents, because it is also set to match_parent. The constant needs
to be changed to a constant that tells it not to fill the screen, which is where the wrap_content
constant comes in.

Figure 6-26. Change child LinearLayout width and height constants to wrap_content; center hello_world TextView

Free download pdf