A (175)

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

Since the layout_width and layout_height parameters are required for every UI tag, copy these from
the parent LinearLayout, and paste them into the child LinearLayout as well. We will get into what
the exact difference is between the match_parent versus wrap_content constants after we define
transparency for a child LinearLayout.


The next thing we need to do is to make your child LinearLayout container transparent, as far as its
background plate is concerned, so the digital image asset that is defined in the parent LinearLayout
container can show through. This is because the default (undefined) layout container background is
white (Holo Light Theme) or black (Holo Dark Theme).


It is important to note that UI containers (and widgets) are stacked on top of each other from the
ground (floor) up, just like you would build a skyscraper. Thus, the parent LinearLayout is on the
bottom, the child LinearLayout containers are on top of that, and the grandchildren TextView widgets
are on top of those.


The hexadecimal value for transparency in Android is #00000000, and the way that color and
transparency are defined using hexadecimal values will be covered in detail in Chapter 9 covering
graphic design for Android.


The android:background parameter can accept a reference to an image asset, to an animation
XML definition, or to other Android drawables, such as a ShapeDrawable, for instance. The
android:background parameter can also accept hexadecimal color and transparency values. To
set the background to be 100% transparent (that is, not present at all), the android:background
parameter would be configured using the following XML mark-up:


android:background="#00000000"


Once these parameters have been put in place in the child tag, as shown in
Figure 6-24, use the Run As ➤ Android Application menu sequence and you will see the result
shown in the middle of Figure 6-20.


Adding String Constants for Use in Your UI Design


Before we add the second nested LinearLayout container to hold the TextView UI widgets that will
hold the actual Galaxy object data values, we must first create the text constants for the
default (pre-modified) values for the data value text UI elements. We will use “My Galaxy” for the
default name and zeroes for the other default values, as shown on the right side of Figure 6-25.

Free download pdf