我试图在一个ScrollView
中水平居中一个StackLayout
。 然而,这个StackLayout
并没有水平居中(它是左对齐的)。 我尝试将ScrollView
居中,但这样整个视图就无法滚动 - 只有中心部分可以滚动。
<ScrollView BackgroundColor="Teal">
<StackLayout Spacing="5"
Padding="30"
WidthRequest="400"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand"
BackgroundColor="Transparent">
<Label Text="Test"/>
<Label Text="Test"/>
<Label Text="Test"/>
<Label Text="Test"/>
</StackLayout>
</ScrollView>
中心对齐可以使用2个嵌套的
StackLayout
元素实现,但是在ScrollView
中不起作用。有什么想法吗?