A (175)

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

Add an android:layout_below and android:layout_alignLeft parameter, and have each of them
reference the edit_colony UI element using @+id/edit_colony. This is done using the
following XML markup:


android:layout_below="@+id/edit_colony" android:layout_alignLeft="@+id/edit_colony"


The first parameter will apply RelativeLayout positioning to the second UI element,
positioning it below the first UI element, using the android:layout_below parameter.
The second parameter will apply RelativeLayout alignment to the second UI
element, aligning it using the left side of each of the UI elements, using the
android:layout_alignLeft parameter.


Let’s click the Graphical Layout tab and preview what these parameters do for our UI design. As you
can see in Figure 7-25, the EditText UI elements line up perfectly, but the second Button UI element
is not toRightOf the EditText UI element as you specified. Or is it? In fact, the second Button UI
element is to the right of EditText, according to the Y axis dimension; however, it is aligned with the
top of the screen next to the other Button! This is the default alignment, unless otherwise specified,
so we will have to add some RelativeLayout alignment parameters to the second

Free download pdf