# Dynamic Scroll

### Overview <a href="#overview" id="overview"></a>

Scroll is a specialized type of Scroll Container intended for high performance where hundreds or thousands of views need to be displayed in a scrollable list.​

{% hint style="info" %}
In Totalcross this component is called **`DynamicScrollContainer`**
{% endhint %}

![](https://1246655713-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L_mPP3a_E_A7NbRMq7Q%2F-LaWF9sycDtqmByWVdaC%2F-LaWGAtAT5cEzA9mr2s0%2Fdynamicscrollcontainer-sample.gif?alt=media\&token=08e88369-40a0-45de-8896-867615ea969b)

{% hint style="info" %}
Because it is a more complex example, which does not only involve the creation of the interface, we have a simpler and more direct example. To access the complete example, just go to our [github](https://github.com/TotalCross/TCSample/blob/master/src/main/java/totalcross/sample/components/ui/DynScrollContainerSample.java).
{% endhint %}

### Source Code <a href="#source-code" id="source-code"></a>

{% code title="DynScrollContainerSample.java" %}

```java
// Creating and positioning the DynamicScrollContainer
vsc = new DynamicScrollContainer();
vsc.setBackColor(Color.WHITE);
vsc.setBorderStyle(BORDER_SIMPLE);
add(vsc, LEFT + gap, AFTER + gap*2, FILL - gap, FILL - gap*2);
// Adding views to the DynamicScrollContainer
DynSCTestView view = new DynSCTestView(array[i], font);
view.height = Settings.screenHeight / 20;
datasource.addView(view);
```

{% endcode %}

### Methods

| Type                                    | Name                                                                 | Description                                                                                                   |
| --------------------------------------- | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| **Constructor**                         | DynamicScrollContainer( )                                            | Creates a empty DynamicScrollContainer.                                                                       |
| **Constructor**                         | DynamicScrollContainer(DynamicScrollContainer.DataSource datasource) | Creates a DynamicScrollContainer that sets the referred datasource                                            |
| **DynamicScrollContainer.AbstractView** | getTopMostVisibleView( )                                             | Return the top most visible view                                                                              |
| **Boolean**                             | isViewVisible(DynamicScrollContainer.AbstractView view)              | Return true if the view is visible                                                                            |
| **Boolean**                             | scrollContent(int dx, int dy, boolean fromFlick)                     | Scroll the DynamicScrollContainer to the referred position. If the boolean is true, it does a flick animation |
| **void**                                | scrollToView(DynamicScrollContainer.AbstractView view)               | Scroll the DynamicScrollContainer to the view                                                                 |
| **void**                                | setDataSource(DynamicScrollContainer.DataSource datasource)          | Set the DataSource                                                                                            |
| **void**                                | stopFlick()                                                          | Stops any flick animation                                                                                     |
