imageNames, int vMargin) {
// Obtain the inflater from the context
LayoutInflater inflater = LayoutInflater.from(context);
// Inflate and attach it as a child of *this* View (ExampleView)
inflater.inflate(R.layout.example, this, true);
}
```
---
# Layout Lab
- clone the [Layout Lab](https://gitlab.cs.washington.edu/cse340/exercises/layoutlab/-/tree/master)
- work on the TODOS in `ProgrammaticConstraints.java` individually or in groups
- relevant to Parts 3 and 4 of Layout Assignment (solutions will be released Friday Night)
---
exclude: true
class: middle, center
# Review
Interactor Hierarchy labeling and drawing trees
Toolkit architecture vs Toolkit library
---
exclude: true
# Review Q1: Drawing Hierarchy
.left-column50[
View Hierarchy question:
- Draw a View Hierarchy based on the screen capture.
- Only include the contents below the top green bar.
]
.right-column50[
![:img Android app showing a vertical list of recent and previous messages, 60%, width](img/examlet_prac_3_layout.png)
]
---
exclude: true
# Review Q1: Drawing Hierarchy
Here's an example of how you should format the View hierarchy
Remember last week's Alarm app example?
.left-column50[
![:img Alarm clock application screenshot and interactor hierarchy, 100%, width](img/alarmclock.png)
]
.right-column50[
![:img Alarm clock view hierarchy, 60%, width](img/viewhierarchy.png)
]
---
exclude: true
# Review Q1: Drawing Hierarchy Answer
.left-column50[
Possible answer:
![:img Possible exam answer showing a hierarchy of Views in the aforementioned example picture, 100%, width](img/examlet_prac_3_ans.png)
]
.right-column50[
![:img Android app showing a vertical list of recent and previous messages, 60%, width](img/examlet_prac_3_layout.png)
]
---
# Exercise 3: Parent-Child Order
Regarding the below tree, list the z-order (from bottom to top) they will be drawn in.
graph TD
Parent -->A[Foo]
Parent -->B[Bar]
Parent -->C[Baz]
Submit your answer in the Question 3 response area of the Section 3 Ed Lesson
---
exclude: true
# Exercise 3: Parent-Child Order
Regarding the below tree, list the z-order (from bottom to top) they will be drawn in.
graph TD
Parent -->A[Foo]
Parent -->B[Bar]
Parent -->C[Baz]
- **1. parent 2. foo 3. bar 4. baz**
---
exclude: true
# Review Q3: Android Methods
- Consider the onMeasure() method that is overridden in Layout Part 3.
- Is this method part of the **toolkit architecture or library?**
---
exclude: true
# Review Q3: Android Methods Answer
- **Answer: Toolkit Architecture**
- "Architecture": the fundamental running code that builds your app
- Includes interactor hierarchy
- Decides structure, redraw, layout, MEASURING stuff!
- Manage your components/app lifecycle
---
exclude: true
# Reminder: Developer roles
graph LR
ip[Interface Programmer]
w[Component Developer]
l[Library Extender]
a[Architecture Extender]
t[Toolkit Builder]
classDef yellow font-size:14pt,text-align:center
classDef green font-size:14pt,text-align:center
classDef darkblue font-size:14pt,text-align:center
class t yellow
class w,l,a green
class ip darkblue
---
exclude: true
# Review: Other Definitions
- [Interface Toolkit](/courses/cse340/23wi/slides/wk01/first-app.html#31): provides services that help you create things
- Used by your program
- Contains library of components, architecture
- "Library": optional COLLECTION of functions, classes, COMPONENTS... that you can include in your app
- Includes ex: ImageView class, ____View class ...etc
- Third Party Libraries
---
# Calculator App
- [This](https://gitlab.cs.washington.edu/cse340/exercises/mvc-calculator/-/tree/section3-layoutonly) is a simple Android calculator app.
- Clone section 3 branch
- Examine src/main/res/layout/activity_main.xml
- How could you refactor or reorganize this code?
- For example: `` tags --> [Android Docs](https://developer.android.com/training/improving-layouts/reusing-layouts)
---
# Exercise 4
- Upload `activity_main.xml` from the Calculator Application with your refactoring changes. List at least 3 refactors you made.
- Your response should be in the following format:
- Refactor 1:
- Refactor 2:
- Refactor 3:
- Uploaded `activity_main.xml` file (click on the paper clip icon to upload a file)
- Submit your answer in the Question 3 response area of the Section 3 Ed Lesson
---
# Need help with Layout? Other Questions?