2.3.9 Nested Views Codehs ~upd~ -
Child position = Parent position + Offset.
Now, create a child that sits inside the parent. The key is that its x and y are relative to the parent’s position . If the parent is at (50, 50), and you want the child at the top-left corner of the parent, you set the child’s position to (50, 50) on the canvas, OR you set it relative to the parent. 2.3.9 nested views codehs
button.setPosition(200, 300); Why it fails: If you move the parent view, the button stays behind. Fix: Always calculate position as parent.getX() + offset . Child position = Parent position + Offset
By following the step-by-step code provided in this guide, avoiding the common pitfalls of direct screen addition, and using proper coordinate math, you will not only pass the autograder but also build a strong foundation for front-end development. If the parent is at (50, 50), and
styles = StyleSheet.create({ container: flex: , backgroundColor: // Change to the color required by the assignment alignItems: // Centers the child view horizontally justifyContent: // Centers the child view vertically , nestedView: { width: , height: , backgroundColor: // Change to the color required by the assignment Use code with caution. Copied to clipboard Key Concepts to Remember: : The parent view uses justifyContent alignItems to control the position of the nested view. Hierarchical Structure : The inner