# Development Guidelines on Container Components Container components are capable of containing UI components and inherit from **UIViewGroup**. Components that are commonly used and need to contain child components are placed in the container class inheritance structure. For example, you need to call the **Add** function to add information such as time statistics and icons to **UIAnalogClock**. **Figure 1** Structure of common container components ![](figure/structure-of-common-container-components.png "structure-of-common-container-components") The **RootView**, **UIAbstractScroll**, and **UIPicker** components inherit from **UIViewGroup**, and the **UIList**, **UIScrollView**, and **UISwipeView** components inherit from **UIAbstractScroll**. ## UIViewGroup ## When to Use **UIViewGroup** is a base class for container components. For example, you can call the functions in this class to add, remove, and insert container components. Also, you can call the **Add** function to add child components for a container component. You need to set the position information for child components in a common container component. The position information is the coordinates relative to those of their parent component. The following figure shows the tree structure of components. **Figure 2** Component tree structure ![](figure/component-tree-structure.png "component-tree-structure") As shown in the figure, the container component **ViewGroup1** and the component **View1** are added to **RootView**, the component **View2** and the container component **ViewGroup2** are added to **ViewGroup1**, and then the component **View3** \(as a sibling of **View1**\) is also added to **ViewGroup1**. - Rendering: During rendering of a container component, you need to call the **OnDraw** function on all its child components to update them. - Coordinates: As the position information of child components is the coordinates relative to those of their parent components, the system calculates and displays the absolute coordinates of child components during rendering. - Tree structure traversing: The **UIViewGroup** class provides the functions below to traverse, search for, and manage the component tree. ## Available APIs **Table 1** Available functions in ViewGroup
virtual void GetTargetView(const Point& point, UIView** last) |
|
void RegisterScrollListener(OnScrollListener* scrollListener) |
|