gpt4 book ai didi

xamarin - 水平 ScrollView - xamarin.forms

转载 作者:行者123 更新时间:2023-12-01 12:37:17 24 4
gpt4 key购买 nike

我知道有很多关于这个主题( Scroll horizontally in Xamarin.Forms ScrollView ),但我无法实现水平滚动的水平 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;
}
}

有任何想法吗?

最佳答案

尝试这个:

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,
};
}

关于xamarin - 水平 ScrollView - xamarin.forms,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28580153/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com