Scrollview 在滚动时向上滚动并覆盖其他内容
Scrollview scrolls up-and-over other content when scrolling
在布置此表单时,我想要一个与其内容大小相同的页眉,与内容大小相同的页脚,以及一个可以扩展以占据其余部分的中间部分。在 XAML/UWP 中很容易。但在 Xamarin Forms 中,当 ScrollView 内容有数据时,它会浮动并覆盖顶部和底部。此外,当我 drag/scroll ScrollView 时,它可以转到屏幕顶部。如何正确停靠滚动视图以便我有一个滚动的中间区域?谢谢...
下面的图片和XAML布局....
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BaseProject.MainPage">
<Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TableView Grid.Row="0" Intent="Settings" BackgroundColor="Blue" HeightRequest="150" >
<TableSection Title="Search">
<ViewCell>
<Button x:Name="Button_Search" Text="Go"/>
</ViewCell>
<EntryCell x:Name="Entry_Cell_SearchFor" />
</TableSection>
</TableView>
<ScrollView Grid.Row="1" VerticalOptions="FillAndExpand" Orientation="Vertical">
<StackLayout BackgroundColor="Red" >
<Label Text="body" x:Name="Label_Body" BackgroundColor="Yellow" />
</StackLayout>
</ScrollView>
<StackLayout Grid.Row="2">
<Label Text="footer"/>
</StackLayout>
</Grid>
</ContentPage>
将 IsClippedToBounds
属性 设置为 true
of ScrollView
在布置此表单时,我想要一个与其内容大小相同的页眉,与内容大小相同的页脚,以及一个可以扩展以占据其余部分的中间部分。在 XAML/UWP 中很容易。但在 Xamarin Forms 中,当 ScrollView 内容有数据时,它会浮动并覆盖顶部和底部。此外,当我 drag/scroll ScrollView 时,它可以转到屏幕顶部。如何正确停靠滚动视图以便我有一个滚动的中间区域?谢谢...
下面的图片和XAML布局....
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BaseProject.MainPage">
<Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TableView Grid.Row="0" Intent="Settings" BackgroundColor="Blue" HeightRequest="150" >
<TableSection Title="Search">
<ViewCell>
<Button x:Name="Button_Search" Text="Go"/>
</ViewCell>
<EntryCell x:Name="Entry_Cell_SearchFor" />
</TableSection>
</TableView>
<ScrollView Grid.Row="1" VerticalOptions="FillAndExpand" Orientation="Vertical">
<StackLayout BackgroundColor="Red" >
<Label Text="body" x:Name="Label_Body" BackgroundColor="Yellow" />
</StackLayout>
</ScrollView>
<StackLayout Grid.Row="2">
<Label Text="footer"/>
</StackLayout>
</Grid>
</ContentPage>
将 IsClippedToBounds
属性 设置为 true
of ScrollView