Hi
I'm creating a horizontal scroll view with dynamic content and can't seem to get it right, no idea why though.
I create a ScrollView panel with UIGrid as a child and attach a horizontal scroll bar as in NGUI scrollView example. When I manually populate the list in Unity by dragging dozen of objects into the uiGrid it all works well. The list is properly filled, and the scroll bar works as intended.
The problems start when I try to add the elements to the grid at runtime from code.
When I add the first element it appears at right location and the scrollbar is hidden (which is expected behaviour).
When I add the second element it appears at right location (after the first one) and the scrollbar appears. The elements are using only part of the clipped panel space so the scroll bar should not appear yet. Also the size of the scrollbar thumb indicates that the list is huge and we are now in the middle of the scroll list which of course is not the case (please check the picture below)

The white items with numbers are the scroll list content. The scroll bar at the bottom is attached to the scroll list and should not be visible yet, since the elements have not yet filled the whole scroll view (red rectangle area).
Here is the code to populate the list. myTimeline is a UIGrid gameObject.
GameObject icon = null;
icon = Instantiate( currentRound.critical ? criticalAttackIconPrefab : attackIconPrefab) as GameObject;
icon.transform.parent = myTimeline.transform;
icon.GetComponent<UIDragScrollView>().scrollView = myTimeline.transform.parent.GetComponent<UIScrollView>();
icon.transform.localScale = Vector3.one;
myTimeline.Reposition ();
I've been trying to get it right for several hours now and seem to be running out of ideas, so any help/suggestions is appreciated.