翻译视图后,它应该滚动完整内容,如果不是,它应该裁剪隐藏部分中的内容 [英] After translating a view it should scroll the full content and if not it should crop the content in the hidden part

查看:21
本文介绍了翻译视图后,它应该滚动完整内容,如果不是,它应该裁剪隐藏部分中的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个查询是这篇文章的延续

在这种情况下,当我设置布局边界时,它会按照第二张图片进行排列,但我需要按照第一张图片进行排列.

解决方案

如果你没有 ScrollView,就像你在 这个问题然后只需将 1 作为 Rectangle 构造函数的最后一个参数.

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

 <Grid AbsoluteLayout.LayoutBounds="{Binding rectNoScroll}"...

rectNoScroll = new Rectangle(0, 250, 1, 1);

当您拥有 ScrollView 时,您可以在 此处 中进行操作.

This query is the continuation of this post Scroll view scrolling not works when the it is translated in y position such that bottom part gets hidden in xamarin forms

Now scroll view works fine, in some cases I used to define like below, I can either use the content of the absolute layout with scroll view or else directly.

When used directly as in below snippet, after translation by setting layout bounds, all the box view were arranged in the specified height.

But previously it will crop at the bottom after translation. I need the same behavior when scroll view is not used. How to achieve this.

        <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>

In this case When I set layout bounds it gets arranged as in second image, but I need as in first image.

解决方案

If you don't have ScrollView, like you had in this question then just put 1 as a last parameter of your Rectangle constructor.

I don't know how the rest of your code looks like, but you can bind different rectangles with different AbsoluteLayout.LayoutBounds. For example, in a case without ScrollView you can put like this

        <AbsoluteLayout x:Name="layout" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Row="1">
         <Grid  AbsoluteLayout.LayoutBounds="{Binding rectNoScroll}"...

rectNoScroll = new Rectangle(0, 250, 1, 1);

and when you have ScrollView you can do like in here.

这篇关于翻译视图后,它应该滚动完整内容,如果不是,它应该裁剪隐藏部分中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆