Choosing a Layout Manager (ViewGroup) and Arranging Components
Author: Ian Darwin --
Published? false --
You want to know how to arrange your GUI components within your view.
There are many layout managers or ViewGroups available. The table below should help you get a handle on which one(s) to use.
As in the case of JavaSE and most other GUI packages, there are multiple components you can use to control the layout of individual GUI components. JavaSE's AWT and Swing provide two classes that work together, Container and LayoutManager. A Container *has a* LayoutManager instance to perform layout calculations on its behalf. Android, having been conceived for smaller devices, combines these two functions into a single class, android.view.ViewGroup. There are many subclasses of ViewGroup intended for you to use. While LinearLayout is the best-known, there are many others. There are also some subclasses that are not intended for use as arbitrary layout managers, such as the drop-down-like Spinner (see 3100).
||Absolute positioning, almost never the right choice!
||Multiple Views in a stack
||Equal-sized Views in rows and columns
||Views in a row or column
||Complex layouts, like HTML tables; more efficient than nesting
||A set of rows each with some number of columns
||Vertical divide of the screen
||Let user flip left and right through pages of data