30.04.2013 Views

Android - CommonsWare

Android - CommonsWare

Android - CommonsWare

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Working with Containers<br />

For example, if Widget A is identified as @+id/widget_a, Widget B can refer<br />

to Widget A in one of its own properties via the identifier @id/widget_a.<br />

Positions Relative to Other Widgets<br />

There are four properties that control position of a widget vis a vis other<br />

widgets:<br />

• android:layout_above indicates that the widget should be placed<br />

above the widget referenced in the property<br />

• android:layout_below indicates that the widget should be placed<br />

below the widget referenced in the property<br />

• android:layout_toLeftOf indicates that the widget should be placed<br />

to the left of the widget referenced in the property<br />

• android:layout_toRightOf indicates that the widget should be placed<br />

to the right of the widget referenced in the property<br />

Beyond those four, there are five additional properties that can control one<br />

widget's alignment relative to another:<br />

• android:layout_alignTop indicates that the widget's top should be<br />

aligned with the top of the widget referenced in the property<br />

• android:layout_alignBottom indicates that the widget's bottom<br />

should be aligned with the bottom of the widget referenced in the<br />

property<br />

• android:layout_alignLeft indicates that the widget's left should be<br />

aligned with the left of the widget referenced in the property<br />

• android:layout_alignRight indicates that the widget's right should<br />

be aligned with the right of the widget referenced in the property<br />

• android:layout_alignBaseline indicates that the baselines of the two<br />

widgets should be aligned (where the "baseline" is that invisible line<br />

that text appears to sit on)<br />

The last one is useful for aligning labels and fields so that the text appears<br />

"natural". Since fields have a box around them and labels do not,<br />

65<br />

Subscribe to updates at http://commonsware.com Special Creative Commons BY-SA 3.0 License Edition

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!