【问题标题】:ScrollOrientation.Both on Xamarin Forms ScrollViewXamarin Forms ScrollView 上的 ScrollOrientation.Both
【发布时间】:2016-06-27 11:17:48
【问题描述】:

有没有人有任何建议允许 ScrollView 允许向任何方向滚动。

似乎只有水平和垂直滚动方向,但没有同时做这两个选项的选项。

我的最终目标是能够在任意方向进行捏合、缩放和滚动。

【问题讨论】:

    标签: xamarin.forms


    【解决方案1】:

    这就是你的做法。

    var scroller = new ScrollView { Content = grid, Orientation= ScrollOrientation.Horizontal, VerticalOptions=LayoutOptions.FillAndExpand };
    var vScroller = new ScrollView (){Content=scroller};
    Content = vScroller;
    

    【讨论】:

    • 它确实有效,但它不允许对角滚动。
    【解决方案2】:

    Xamarin Forms 滚动视图的 Orientation 属性现在接受 Both 作为值。它在两个方向上滚动。我正在使用 Xamarin Forms 版本 2.3.0.49。

    <ScrollView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Orientation="Both">

    【讨论】:

    • 这对我不起作用。它会导致运行时异常。 Xamarin 表单版本 2.3.3.180。
    【解决方案3】:

    ScrollOrientation 不是[Flags] 枚举并且不包含Both 值,所以我目前不支持。但这可能有效:

    new ScrollView {
        Orientation = ScrollOrientation.Vertical,
        Content = new ScrollView {
            Orientation = ScrollOrientation.Horizontal,
            Content = your_content_goes_here,
        }
    }
    

    【讨论】:

    • 它与来自 user2986451 的代码基本相同,这对我有用。你的Content 是什么?我在内部水平滚动视图的StackLayout 中使用Label。什么不起作用?只有一个滚动方向?
    • 文档说不要将滚动视图放在滚动视图中 docs.microsoft.com/en-us/dotnet/api/…
    猜你喜欢
    • 2021-01-15
    • 2016-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-18
    • 2014-09-13
    • 1970-01-01
    相关资源
    最近更新 更多