1e41f4b71Sopenharmony_ci# Container Component Development<a name="EN-US_TOPIC_0000001052810390"></a> 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciContainer 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**. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci**Figure 1** Structure of common container components<a name="fig1931013319293"></a> 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ciThe **RootView**, **UIAbstractScroll**, and **UIPicker** components inherit from **UIViewGroup**, and the **UIList**, **UIScrollView**, and **UISwipeView** components inherit from **UIAbstractScroll**. 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## UIViewGroup<a name="section145471898812"></a> 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci## When to Use<a name="section0916112362216"></a> 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci**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. 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci**Figure 2** Component tree structure<a name="fig279970183012"></a> 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ciAs 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**. 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci- Rendering: During rendering of a container component, you need to call the **OnDraw** function on all its child components to update them. 22e41f4b71Sopenharmony_ci- 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. 23e41f4b71Sopenharmony_ci- Tree structure traversing: The **UIViewGroup** class provides the functions below to traverse, search for, and manage the component tree. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci## Available APIs<a name="section12641756192212"></a> 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**Table 1** Available functions in ViewGroup 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci<a name="table15959122392211"></a> 30e41f4b71Sopenharmony_ci<table><thead align="left"><tr id="row14957132342220"><th class="cellrowborder" valign="top" width="64.73%" id="mcps1.2.3.1.1"><p id="p3957182302217"><a name="p3957182302217"></a><a name="p3957182302217"></a>Function</p> 31e41f4b71Sopenharmony_ci</th> 32e41f4b71Sopenharmony_ci<th class="cellrowborder" valign="top" width="35.27%" id="mcps1.2.3.1.2"><p id="p1595742312219"><a name="p1595742312219"></a><a name="p1595742312219"></a>Description</p> 33e41f4b71Sopenharmony_ci</th> 34e41f4b71Sopenharmony_ci</tr> 35e41f4b71Sopenharmony_ci</thead> 36e41f4b71Sopenharmony_ci<tbody><tr id="row14957123162218"><td class="cellrowborder" valign="top" width="64.73%" headers="mcps1.2.3.1.1 "><p id="p89572023102216"><a name="p89572023102216"></a><a name="p89572023102216"></a>virtual void Add(UIView* view)</p> 37e41f4b71Sopenharmony_ci</td> 38e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="35.27%" headers="mcps1.2.3.1.2 "><p id="p1495720236223"><a name="p1495720236223"></a><a name="p1495720236223"></a>Adds a child component.</p> 39e41f4b71Sopenharmony_ci</td> 40e41f4b71Sopenharmony_ci</tr> 41e41f4b71Sopenharmony_ci<tr id="row895892310224"><td class="cellrowborder" valign="top" width="64.73%" headers="mcps1.2.3.1.1 "><p id="p16958192315227"><a name="p16958192315227"></a><a name="p16958192315227"></a>virtual void Insert(UIView* prevView, UIView* insertView)</p> 42e41f4b71Sopenharmony_ci</td> 43e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="35.27%" headers="mcps1.2.3.1.2 "><p id="p1958223152210"><a name="p1958223152210"></a><a name="p1958223152210"></a>Inserts a child component.</p> 44e41f4b71Sopenharmony_ci</td> 45e41f4b71Sopenharmony_ci</tr> 46e41f4b71Sopenharmony_ci<tr id="row395862315229"><td class="cellrowborder" valign="top" width="64.73%" headers="mcps1.2.3.1.1 "><p id="p16958142314223"><a name="p16958142314223"></a><a name="p16958142314223"></a>virtual void Remove(UIView* view)</p> 47e41f4b71Sopenharmony_ci</td> 48e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="35.27%" headers="mcps1.2.3.1.2 "><p id="p2095862319224"><a name="p2095862319224"></a><a name="p2095862319224"></a>Removes a child component.</p> 49e41f4b71Sopenharmony_ci</td> 50e41f4b71Sopenharmony_ci</tr> 51e41f4b71Sopenharmony_ci<tr id="row195832352212"><td class="cellrowborder" valign="top" width="64.73%" headers="mcps1.2.3.1.1 "><p id="p3958152362219"><a name="p3958152362219"></a><a name="p3958152362219"></a>virtual void RemoveAll()</p> 52e41f4b71Sopenharmony_ci</td> 53e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="35.27%" headers="mcps1.2.3.1.2 "><p id="p10958132318225"><a name="p10958132318225"></a><a name="p10958132318225"></a>Removes all child components.</p> 54e41f4b71Sopenharmony_ci</td> 55e41f4b71Sopenharmony_ci</tr> 56e41f4b71Sopenharmony_ci<tr id="row895818232223"><td class="cellrowborder" valign="top" width="64.73%" headers="mcps1.2.3.1.1 "><p id="p9958202322214"><a name="p9958202322214"></a><a name="p9958202322214"></a>virtual void GetTargetView(const Point& point, UIView** last)</p> 57e41f4b71Sopenharmony_ci</td> 58e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="35.27%" headers="mcps1.2.3.1.2 "><p id="p79584234227"><a name="p79584234227"></a><a name="p79584234227"></a>Obtains the target view.</p> 59e41f4b71Sopenharmony_ci</td> 60e41f4b71Sopenharmony_ci</tr> 61e41f4b71Sopenharmony_ci<tr id="row795917235227"><td class="cellrowborder" valign="top" width="64.73%" headers="mcps1.2.3.1.1 "><p id="p5958162362213"><a name="p5958162362213"></a><a name="p5958162362213"></a>virtual void MoveChildByOffset(int16_t x, int16_t y)</p> 62e41f4b71Sopenharmony_ci</td> 63e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="35.27%" headers="mcps1.2.3.1.2 "><p id="p18958142315225"><a name="p18958142315225"></a><a name="p18958142315225"></a>Moves a child component by a specified offset.</p> 64e41f4b71Sopenharmony_ci</td> 65e41f4b71Sopenharmony_ci</tr> 66e41f4b71Sopenharmony_ci<tr id="row1395912314227"><td class="cellrowborder" valign="top" width="64.73%" headers="mcps1.2.3.1.1 "><p id="p209591223172217"><a name="p209591223172217"></a><a name="p209591223172217"></a>UIView* GetChildrenHead() const</p> 67e41f4b71Sopenharmony_ci</td> 68e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="35.27%" headers="mcps1.2.3.1.2 "><p id="p895942313224"><a name="p895942313224"></a><a name="p895942313224"></a>Obtains the first child view in a view group.</p> 69e41f4b71Sopenharmony_ci</td> 70e41f4b71Sopenharmony_ci</tr> 71e41f4b71Sopenharmony_ci<tr id="row7959192317226"><td class="cellrowborder" valign="top" width="64.73%" headers="mcps1.2.3.1.1 "><p id="p89591423122213"><a name="p89591423122213"></a><a name="p89591423122213"></a>UIView* GetChildrenTail() const</p> 72e41f4b71Sopenharmony_ci</td> 73e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="35.27%" headers="mcps1.2.3.1.2 "><p id="p17959132382217"><a name="p17959132382217"></a><a name="p17959132382217"></a>Obtains the last child view in a view group.</p> 74e41f4b71Sopenharmony_ci</td> 75e41f4b71Sopenharmony_ci</tr> 76e41f4b71Sopenharmony_ci<tr id="row39591423142214"><td class="cellrowborder" valign="top" width="64.73%" headers="mcps1.2.3.1.1 "><p id="p6959623182212"><a name="p6959623182212"></a><a name="p6959623182212"></a>virtual UIView* GetChildById(const char* id) const override</p> 77e41f4b71Sopenharmony_ci</td> 78e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="35.27%" headers="mcps1.2.3.1.2 "><p id="p095932319222"><a name="p095932319222"></a><a name="p095932319222"></a>Obtains a child view based on its ID.</p> 79e41f4b71Sopenharmony_ci</td> 80e41f4b71Sopenharmony_ci</tr> 81e41f4b71Sopenharmony_ci</tbody> 82e41f4b71Sopenharmony_ci</table> 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci## How to Develop<a name="section5412161692311"></a> 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci1. Create **ULLabelButton** instances and set their coordinates. 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci ``` 89e41f4b71Sopenharmony_ci UILabelButton* btn1 = new UILabelButton(); 90e41f4b71Sopenharmony_ci btn1->SetPosition(0, 0, 100, 50); 91e41f4b71Sopenharmony_ci btn1->SetText("btn1"); 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci UILabelButton* btn2 = new UILabelButton(); 94e41f4b71Sopenharmony_ci btn2->SetPosition(50, 50, 100, 50); 95e41f4b71Sopenharmony_ci btn2->SetText("btn2"); 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci UILabelButton* btn3 = new UILabelButton(); 98e41f4b71Sopenharmony_ci btn3->SetPosition(100, 100, 100, 50); 99e41f4b71Sopenharmony_ci btn3->SetText("btn3"); 100e41f4b71Sopenharmony_ci ``` 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ci2. Create a **UIViewGroup** instance and set its coordinates. 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci ``` 105e41f4b71Sopenharmony_ci UIViewGroup* group = new UIViewGroup(); 106e41f4b71Sopenharmony_ci group->SetPosition(0, 0, 300, 300); 107e41f4b71Sopenharmony_ci ``` 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_ci3. Add the **ULLabelButton** instances to **UIViewGroup**. 110e41f4b71Sopenharmony_ci 111e41f4b71Sopenharmony_ci ``` 112e41f4b71Sopenharmony_ci group->Add(btn1); 113e41f4b71Sopenharmony_ci group->Add(btn2); 114e41f4b71Sopenharmony_ci group->Add(btn3); 115e41f4b71Sopenharmony_ci ``` 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ci4. The following figure shows the effect of adding view instances to a **ViewGroup**. 118e41f4b71Sopenharmony_ci 119e41f4b71Sopenharmony_ci **Figure 3** Effect of adding view instances to a ViewGroup<a name="fig33041856184219"></a> 120e41f4b71Sopenharmony_ci  121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ci## UIScrollView<a name="section174961523161315"></a> 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_ci## When to Use<a name="section8937101902413"></a> 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci**UIScrollView** provides scrolling container components, which enable child components to scroll upwards, downwards, leftwards, and rightwards upon a touch event. This class also supports horizontal and vertical cursor display. 128e41f4b71Sopenharmony_ci 129e41f4b71Sopenharmony_ci## Available APIs<a name="section14789133142420"></a> 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci**Table 2** Available functions in ScrollView 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ci<a name="table73572052411"></a> 134e41f4b71Sopenharmony_ci<table><thead align="left"><tr id="row432202014249"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p432142092415"><a name="p432142092415"></a><a name="p432142092415"></a>Function</p> 135e41f4b71Sopenharmony_ci</th> 136e41f4b71Sopenharmony_ci<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p4323208245"><a name="p4323208245"></a><a name="p4323208245"></a>Description</p> 137e41f4b71Sopenharmony_ci</th> 138e41f4b71Sopenharmony_ci</tr> 139e41f4b71Sopenharmony_ci</thead> 140e41f4b71Sopenharmony_ci<tbody><tr id="row13392032417"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p632182022417"><a name="p632182022417"></a><a name="p632182022417"></a>void ScrollBy(int16_t xDistance, int16_t yDistance)</p> 141e41f4b71Sopenharmony_ci</td> 142e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p13333208242"><a name="p13333208242"></a><a name="p13333208242"></a>Scrolls a view.</p> 143e41f4b71Sopenharmony_ci</td> 144e41f4b71Sopenharmony_ci</tr> 145e41f4b71Sopenharmony_ci<tr id="row1633132032415"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1533320172413"><a name="p1533320172413"></a><a name="p1533320172413"></a>void SetScrollbarWidth(uint8_t width)</p> 146e41f4b71Sopenharmony_ci</td> 147e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p173322015241"><a name="p173322015241"></a><a name="p173322015241"></a>Sets the scrollbar width.</p> 148e41f4b71Sopenharmony_ci</td> 149e41f4b71Sopenharmony_ci</tr> 150e41f4b71Sopenharmony_ci<tr id="row033152012416"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p173382042417"><a name="p173382042417"></a><a name="p173382042417"></a>void SetHorizontalScrollState(bool state)</p> 151e41f4b71Sopenharmony_ci</td> 152e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p103362042411"><a name="p103362042411"></a><a name="p103362042411"></a>Sets the horizontal scrolling state.</p> 153e41f4b71Sopenharmony_ci</td> 154e41f4b71Sopenharmony_ci</tr> 155e41f4b71Sopenharmony_ci<tr id="row03362011242"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p333152032413"><a name="p333152032413"></a><a name="p333152032413"></a>bool GetHorizontalScrollState() const</p> 156e41f4b71Sopenharmony_ci</td> 157e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p9331220192418"><a name="p9331220192418"></a><a name="p9331220192418"></a>Checks whether horizontal scrolling is allowed.</p> 158e41f4b71Sopenharmony_ci</td> 159e41f4b71Sopenharmony_ci</tr> 160e41f4b71Sopenharmony_ci<tr id="row1933520142413"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1833520192410"><a name="p1833520192410"></a><a name="p1833520192410"></a>void SetVerticalScrollState(bool state)</p> 161e41f4b71Sopenharmony_ci</td> 162e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p12331520132415"><a name="p12331520132415"></a><a name="p12331520132415"></a>Sets the vertical scrolling state.</p> 163e41f4b71Sopenharmony_ci</td> 164e41f4b71Sopenharmony_ci</tr> 165e41f4b71Sopenharmony_ci<tr id="row183318200243"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p63317207248"><a name="p63317207248"></a><a name="p63317207248"></a>bool GetVerticalScrollState() const</p> 166e41f4b71Sopenharmony_ci</td> 167e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1133020112417"><a name="p1133020112417"></a><a name="p1133020112417"></a>Checks whether vertical scrolling is allowed.</p> 168e41f4b71Sopenharmony_ci</td> 169e41f4b71Sopenharmony_ci</tr> 170e41f4b71Sopenharmony_ci<tr id="row43462072418"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p193313203245"><a name="p193313203245"></a><a name="p193313203245"></a>void SetXScrollBarVisible(bool state)</p> 171e41f4b71Sopenharmony_ci</td> 172e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1833102017242"><a name="p1833102017242"></a><a name="p1833102017242"></a>Sets whether the x-axis scrollbar is visible.</p> 173e41f4b71Sopenharmony_ci</td> 174e41f4b71Sopenharmony_ci</tr> 175e41f4b71Sopenharmony_ci<tr id="row1834720132417"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p8341620162410"><a name="p8341620162410"></a><a name="p8341620162410"></a>void SetYScrollBarVisible(bool state)</p> 176e41f4b71Sopenharmony_ci</td> 177e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p163462092412"><a name="p163462092412"></a><a name="p163462092412"></a>Sets whether the y-axis scrollbar is visible.</p> 178e41f4b71Sopenharmony_ci</td> 179e41f4b71Sopenharmony_ci</tr> 180e41f4b71Sopenharmony_ci<tr id="row13482082411"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p33415208244"><a name="p33415208244"></a><a name="p33415208244"></a>void RegisterScrollListener(OnScrollListener* scrollListener)</p> 181e41f4b71Sopenharmony_ci</td> 182e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p934112002417"><a name="p934112002417"></a><a name="p934112002417"></a>Registers the scrolling callback class.</p> 183e41f4b71Sopenharmony_ci</td> 184e41f4b71Sopenharmony_ci</tr> 185e41f4b71Sopenharmony_ci<tr id="row934192014242"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p18341020132410"><a name="p18341020132410"></a><a name="p18341020132410"></a>void RefreshScrollBar()</p> 186e41f4b71Sopenharmony_ci</td> 187e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p234520192417"><a name="p234520192417"></a><a name="p234520192417"></a>Refreshes the scrollbar.</p> 188e41f4b71Sopenharmony_ci</td> 189e41f4b71Sopenharmony_ci</tr> 190e41f4b71Sopenharmony_ci<tr id="row63422072418"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p8341620172411"><a name="p8341620172411"></a><a name="p8341620172411"></a>virtual void OnScrollStart() {}</p> 191e41f4b71Sopenharmony_ci</td> 192e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p193452052417"><a name="p193452052417"></a><a name="p193452052417"></a>Called when scrolling starts.</p> 193e41f4b71Sopenharmony_ci</td> 194e41f4b71Sopenharmony_ci</tr> 195e41f4b71Sopenharmony_ci<tr id="row93432017244"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p143416203242"><a name="p143416203242"></a><a name="p143416203242"></a>virtual void OnScrollEnd() {}</p> 196e41f4b71Sopenharmony_ci</td> 197e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p534152018243"><a name="p534152018243"></a><a name="p534152018243"></a>Called when scrolling ends.</p> 198e41f4b71Sopenharmony_ci</td> 199e41f4b71Sopenharmony_ci</tr> 200e41f4b71Sopenharmony_ci<tr id="row33532012247"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1834172052419"><a name="p1834172052419"></a><a name="p1834172052419"></a>uint8_t GetScrollState() const</p> 201e41f4b71Sopenharmony_ci</td> 202e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1346205242"><a name="p1346205242"></a><a name="p1346205242"></a>Obtains the scrolling state.</p> 203e41f4b71Sopenharmony_ci</td> 204e41f4b71Sopenharmony_ci</tr> 205e41f4b71Sopenharmony_ci<tr id="row1535142022415"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p173532082413"><a name="p173532082413"></a><a name="p173532082413"></a>void SetScrollState(uint8_t state)</p> 206e41f4b71Sopenharmony_ci</td> 207e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1235102016242"><a name="p1235102016242"></a><a name="p1235102016242"></a>Sets the scrolling state.</p> 208e41f4b71Sopenharmony_ci</td> 209e41f4b71Sopenharmony_ci</tr> 210e41f4b71Sopenharmony_ci</tbody> 211e41f4b71Sopenharmony_ci</table> 212e41f4b71Sopenharmony_ci 213e41f4b71Sopenharmony_ci## How to Develop<a name="section1769754422417"></a> 214e41f4b71Sopenharmony_ci 215e41f4b71Sopenharmony_ciAdd two buttons as child components and display horizontal and vertical cursors. 216e41f4b71Sopenharmony_ci 217e41f4b71Sopenharmony_ci``` 218e41f4b71Sopenharmony_ciscrollView* scroll = new UIScrollView(); 219e41f4b71Sopenharmony_ciscroll->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full); 220e41f4b71Sopenharmony_ciscroll->SetPosition(0,0, 200, 200); 221e41f4b71Sopenharmony_ciscroll->SetXScrollBarVisible(true); 222e41f4b71Sopenharmony_ciscroll->SetYScrollBarVisible(true); 223e41f4b71Sopenharmony_ciUILabelButton* button1 = new UILabelButton(); 224e41f4b71Sopenharmony_cibutton1->SetText("button1"); 225e41f4b71Sopenharmony_cibutton1->SetPosition(0, 0, 300, 300); 226e41f4b71Sopenharmony_ciUILabelButton* button2 = new UILabelButton(); 227e41f4b71Sopenharmony_cibutton2->SetText("button2"); 228e41f4b71Sopenharmony_cibutton2->SetPosition(0, 300, 300, 300); 229e41f4b71Sopenharmony_ciscroll->Add(button1); 230e41f4b71Sopenharmony_ciscroll->Add(button2); 231e41f4b71Sopenharmony_ci``` 232e41f4b71Sopenharmony_ci 233e41f4b71Sopenharmony_ci**Figure 4** Scrolling effect in both horizontal and vertical directions<a name="fig99017432114"></a> 234e41f4b71Sopenharmony_ci 235e41f4b71Sopenharmony_ci 236