Xamarin Forms 4.1:ScrollView滚动覆盖了android设备9.0中的标题视图

时间:2019-10-04 09:55:42

标签: xamarin.forms scroll scrollview

在Xamarin Forms 4.1中,滚动时,scrollview内容覆盖/溢出了headerview,而scrollview内容未完全显示。

尝试将 IsClippedToBounds 设置为true。 创建了scrollviewrenderer,OnDraw()->将clip设置为bound属性。但是没有用。

示例:这是XAML设计

 <Stacklayout>
      <HeaderView/>
      <ScrollView IsClippedToBounds="true">
          <Stacklayout>
                <label text="1"/>
                 ........
                 ........
                <label text="100"/>
          </Stacklayout>
      </ScrollView>
</Stacklayout>

2 个答案:

答案 0 :(得分:0)

如果您希望标题始终可见,而不是将内容放在标题中,则最好先放置标题内容,然后再将其放置在列表视图下方。因此,您的标题保持不变,并且listview滚动。

答案 1 :(得分:0)

我将自定义控件作为您描述中的headerview。并在Xamarin.forms 4.1上进行测试,效果很好。

MyCustomConrol:

<StackLayout Orientation="Horizontal"  BackgroundColor="Aqua">
    <Label x:Name="Title_label" Text="Title" TextColor="Black" FontSize="25"  HorizontalOptions="StartAndExpand" Margin="8,0,4,0"/>
    <Button x:Name="btnHello" Text="Hello" HorizontalOptions="EndAndExpand" Margin="4,0,8,0"/>
</StackLayout>

MainPage.xaml

<StackLayout>
    <local:MyCustomControl></local:MyCustomControl>
    <!--<HeaderView/>-->
    <ScrollView IsClippedToBounds="true">
        <StackLayout>
            <Label Text="1"/>
            <Label Text="2"/>
            <Label Text="3"/>
               ……………
               …………………
        </StackLayout>
    </ScrollView>

结果:

enter image description here

您可以从GitHub的ScrollView / XamarinDemo文件夹下载以供参考。 https://github.com/WendyZang/Test.git