Android UI Development
- A typical application will include
- Acitivties (MainActivity as entry point)
- Views (Screen layouts, ViewGroups)
- Intents (multiple Activity screens
Layouts
- Defines the structure of a user interface in your app
- Can be nested
- When you compile your app, each XML layout file is compiled into a view source
View (Widget)
Properties
- background colour
- Text
- Font alignment
- Size
- Padding/margin
- etc.
Event Listener and Handlers
- Respond to various events such as click, long-click, focus change etc.
Set focus
- Set focus on a specific view requestFocus() or use XML tag <requestFocus />
Visibility
- You can hide or show views using setVisibility()
Linear Layout
- A view group that aligns all children in a single direction, vertically or horizontally
- All children of a LinearLayout are stacked one after the other
- A vertical list will only have one child per row
- A horizontal list will only be one row high
Orientation - vertical or horizontal?
Fill model - how will the child be filling the parent
Weight - assigns an "importance" value to view in terms how much space it would occupy on the screen
Relative Layout
- A ViewGroup that display child views in relative positions
- The position of each view can be specified as
- Relative to sibling elements
- In positions relative to the parent
Constraint Layout
- Similar to RelativeLayout
- All views are laid out according to relationships with others