When using a scrollview my expectation would be that as long as the elements displayed in the scrollview do not cover the whole area the elements would stick to the top and scrolling is disabled. As soon as there are more elements than space available scrolling should be enabled.
But what I actually see is that if I have only one element in my scrollview the user could move it to the bottom.
Is this intentional or is this a bug? Am I missing some settings to specify the behavior?
I create my scrollview using UXML and add the elements to it later using code in C#.
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/UI%20Toolkit/MainMenu.uss?fileID=7433441132597879392&guid=8ce16d8eca0494c43a96da937adbe094&type=3#MainMenu" />
<ui:VisualElement style="flex-grow: 1; justify-content: center; align-items: center;">
<ui:ScrollView scroll-deceleration-rate="0,135" elasticity="0,1" vertical-scroller-visibility="Hidden" horizontal-scroller-visibility="Hidden" name="list" style="width: 1400px; height: 2460px; border-top-left-radius: 15px; border-bottom-left-radius: 15px; border-top-right-radius: 15px; border-bottom-right-radius: 15px;" />
</ui:VisualElement>
</ui:UXML>
The CSS does not contain any styles for the scrollview. It is only for the elements that I add later.
I couldn’t find any hint in the documentation and google gave me a lot of results that were only related to other problems with scrollview. Does anyone have a similar problem?