A (175)

(Tuis.) #1
CHAPTER 7: Making Apps Interactive: Intents, Event Handling, and Menus 247

Using Baseline Alignment: The layout_alignBaseline Parameter


Add a new line inside of the third UI widget after the android:layout_alignLeft parameter, and
add in an android:layout_alignBaseline parameter that references the third submit_fleet Button UI ID
value, using the following XML markup, as is shown in the top XML editing pane portion of Figure 7 -3 1 :


android:layout_alignBaseline="@+id/submit_fleet"


After you have added in this parameter, click on the Graphical Layout Editor tab at the bottom of the
editing pane to switch over into visual layout design mode, and as you can see in Figure 7-31, the
third EditText UI element is now perfectly aligned with the third Button UI element.


Also notice that all of the RelativeLayout alignment parameters are shown in the visual layout
mode using green arrows. The green arrow pointing up shows the android:layout_below parameter,
and the green arrow pointing to the left (on the left) shows the android:layout_alignLeft with the
edit_colony EditText at the top of the UI design (which is indicated by a left pointing green arrow
next to this edit_colony EditText UI element), and the android:alignBaseline parameter is shown by
Eclipse drawing a dashed green baseline underneath all of the text.


The long green arrow coming out of the Button UI element and pointing at the EditView UI element
is showing the android:layout_toRightOf parameter for the Button UI element, which references the
@+id/edit_fleet ID for the EditText UI element, just in case you are wondering what that particular
green arrow is referencing.


Figure 7-31. Using the android:layout_alignBaseline parameter to align your widget with the

Free download pdf