Nested Views Codehs ((install)): 2.3.9

CodeHS 2.3.9: Nested Views in the Mobile Apps (React Native) course, the objective is to create a specific layout by placing components inside other

In React Native, every component is wrapped in a main container. For this exercise, you typically have one top-level View (the container) that holds multiple inner Views. Container (Parent): Holds everything and usually has to fill the whole screen. Nested Views (Children): Sub-sections inside the parent. Define the Stylesheet You must use the CodeHS Stylesheet API to give each View a specific size, color, or flex value. Determines how much space a View takes relative to others. FlexDirection: Sets whether nested views stack vertically ( ) or horizontally ( Basic Code Structure 2.3.9 nested views codehs

Conclusion: CodeHS 2.3.9 is a well-designed exercise that transforms students from beginners into layout architects. It is challenging enough to demand focus but structured enough to ensure success if the syntax is followed correctly. CodeHS 2

// Create the main view
var mainView = new View(0, 0, 400, 400);
mainView.setBackground("white");

Style Overlap: Remember that styles applied to a parent view (like justifyContent) will dictate the position of all nested child views. Why This Lesson Matters Explanation:

Hierarchy: Use at least four View components nested inside each other.

The goal is to nest one or more components inside a parent to practice how children align based on the parent's style attributes. Key Concepts for Nested Views

// Header child view (inside parent)
var headerView = new Rectangle(260, 50);
headerView.setColor("navy");
headerView.setPosition(parentView.getX() + 20, parentView.getY() + 20);
add(headerView);

Explanation: