191 Lecture 4
191 Lecture 4
9/14/2011
Layouts
Layouts are ViewGroups Common layouts: which are used to hold FrameLayout other Views
LinearLayout
Invisible Allow positioning of different elements Layouts can be nested inside of each other
http://developer.android.com/guide/topics/ui/layout-objects.html
Tricky: 1) ids dont map to 0,1,2,3 2) weights in XML are integer strings, in code floats
The XML is compiled into resources The view resource created can auto-magically be inflated at runtime Can programmatically access other definitions, such as IDs, made in XML
Reference the id Resource, get View associated with that id button = (Button)findViewById(R.id.button1);
RelativeLayout
A Layout where the location for Views that are added can be described:
Relative to other Views added (to the left of X) Relative to the RelativeLayout container (aligned to the container bottom)
Remember, two styles: Relative to some other view (layout_below) Relative to RelativeLayout container parent (alignParentLeft)
If row of Buttons uses horizontal LinearLayout, would be next to each other instead of pushed to borders of screen