Lecture 3: Views and Viewgroups Flashcards
What are the categories Android UI elements can be broken down into?
- Views
- Viewgroups
What is the difference between a view and a viewgroup?
View: Any UI element with actual visual presence, (ie: button, text, label)
Viewgroup: An organization tool for views, typically layouts used to organize views
What is the purpose of the R file?
- Used during the activity creation to load existing XML layout to use as the UI for the activity
- Use the R file to reference objects - both views as well as viewgroups within the UI
Classes that extend the ViewGroup class are typically known as ___
layouts
What are the most important attributes for a viewgroup and how are they defined?
- layout_height
- layout_width
defined as one of the following:
- integer values
- dp (resolution-independent pixels)
- wrap_content
- match_parent
Whats the difference between wrap_content and match_parent?
wrap_content: layout sizes itself to its content
match_parent: layout sizes itself to its parent object
What are the types of viewgroups discussed in class?
- LinearLayout
- ConstraintLayout
- Webviews
- TableLayout
- Adapters
Describe the linearlayout class
Organizes view into a linear list interface
Organizes items vertically or horizontally with the orientation attribute
Describe the constraintlayout class
Lets you define the layout of views relative to other view elements
Describe the webview class
Allows you to render web content within your app (HTML, images, CSS)
Useful for hooking up external web apps to your android app or for pulling resources from an external website for your app
What type of viewgroup is used to handle UI elements that are going to be dynamically generated at runtime?
Adapters
Allow the layout to be dynamically filled using code, rather than predefined XML