【问题标题】:After translating a view it should scroll the full content and if not it should crop the content in the hidden part翻译视图后,它应该滚动全部内容,如果没有,它应该裁剪隐藏部分的内容
【发布时间】:2021-08-02 11:52:11
【问题描述】:

此查询是本文Scroll view scrolling not works when the it is translated in y position such that bottom part gets hidden in xamarin forms的延续

现在滚动视图工作正常,在某些情况下,我曾经定义如下,我可以将绝对布局的内容与滚动视图一起使用,也可以直接使用。

在sn-p下面直接使用时,通过设置layout bounds平移后,所有box view都排列在指定的高度。

但以前它会在翻译后在底部裁剪。当不使用滚动视图时,我需要相同的行为。如何做到这一点。

        <AbsoluteLayout x:Name="layout" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Row="1">

         <Grid  x:Name="scrollView" AbsoluteLayout.LayoutFlags="SizeProportional" AbsoluteLayout.LayoutBounds="0,0,1,1" >
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <BoxView Grid.Row="0" BackgroundColor="Red"></BoxView>
            <BoxView Grid.Row="1" BackgroundColor="Black"></BoxView>

            <BoxView Grid.Row="2" BackgroundColor="Blue"></BoxView>
            <BoxView Grid.Row="3" BackgroundColor="Gray"></BoxView>
            <BoxView Grid.Row="4" BackgroundColor="Green"></BoxView>
            <BoxView Grid.Row="5" BackgroundColor="Red"></BoxView>
            <BoxView Grid.Row="6" BackgroundColor="Black"></BoxView>

            <BoxView Grid.Row="7" BackgroundColor="Blue"></BoxView>
            <BoxView Grid.Row="8" BackgroundColor="Gray"></BoxView>
            <BoxView Grid.Row="9" BackgroundColor="Green"></BoxView>
        </Grid>

在这种情况下,当我设置布局边界时,它会像第二张图片一样排列,但我需要像第一张图片一样。

【问题讨论】:

    标签: xamarin.forms scrollview absolutelayout


    【解决方案1】:

    如果您没有 ScrollView,就像在 this question 中一样,那么只需将 1 作为您的 Rectangle 构造函数的最后一个参数。

    我不知道你的其余代码是什么样子的,但你可以用不同的AbsoluteLayout.LayoutBounds 绑定不同的矩形。例如,在没有 ScrollView 的情况下,您可以这样放置

            <AbsoluteLayout x:Name="layout" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Row="1">
             <Grid  AbsoluteLayout.LayoutBounds="{Binding rectNoScroll}"...
    
    rectNoScroll = new Rectangle(0, 250, 1, 1);
    

    当你有ScrollView 时,你可以像here 那样做。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-27
      • 1970-01-01
      • 1970-01-01
      • 2019-04-27
      • 1970-01-01
      • 2012-04-12
      相关资源
      最近更新 更多