【问题标题】:Horizontal ScrollView - xamarin.forms水平滚动视图 - xamarin.forms
【发布时间】:2015-02-18 09:35:19
【问题描述】:

我知道这个话题有很多(Scroll horizontally in Xamarin.Forms ScrollView),但我无法实现水平滚动的水平滚动视图。

public class DetailView : ContentPage
{
    public DetailView ()
    {
        StackLayout stack = new StackLayout {
            Orientation = StackOrientation.Horizontal,
            };
        for (int i = 0; i < 40; i++)
            stack.Children.Add (new Button { Text = "Button" });
        var scrollView = new ScrollView
        {
            Orientation = ScrollOrientation.Horizontal,
            Content = stack
        };
        Content = scrollView;
    }   
}

有什么想法吗?

【问题讨论】:

    标签: xamarin scrollview xamarin.forms content-pages


    【解决方案1】:

    试试这个:

    public DetailView()
    {
        var scrollableContent = new StackLayout()
        {
            Orientation = StackOrientation.Horizontal,
            HorizontalOptions = LayoutOptions.Fill,
            Children =
            {
                new BoxView(){HeightRequest=40, WidthRequest=40, BackgroundColor = Color.Red},
                new BoxView(){HeightRequest=40, WidthRequest=40, BackgroundColor = Color.Green},
                new BoxView(){HeightRequest=40, WidthRequest=40, BackgroundColor = Color.Blue},
                new BoxView(){HeightRequest=40, WidthRequest=40, BackgroundColor = Color.Maroon},
            }
        };
    
        Content = new ScrollView()
        {
            HorizontalOptions = LayoutOptions.FillAndExpand,
            Orientation = ScrollOrientation.Horizontal,
            Content = scrollableContent,
        };
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多