我想要水平滚动一些数字(0-23)作为它的项目水平listview。降低水平列表视图的高度 - xamarin表格
我得到的列表视图是水平的,但listview的高度没有被包装到内容。我试着用xConstraint,yConstraint,width和heightConstraint使用RelativeLayout,我试着改变它的参数值,但是listview消失了所有的时间我改变了值。
ListView lv = new ListView
{
SeparatorVisibility = SeparatorVisibility.None,
ItemsSource = items,
Rotation = 270,
ItemTemplate = new DataTemplate(() =>
{
Label label = new Label()
{
Rotation = 90,
TextColor = Color.Black,
HorizontalTextAlignment = TextAlignment.Center,
FontSize = Device.GetNamedSize(NamedSize.Small, new Label())
};
label.SetBinding<User>(Label.TextProperty, indexer => indexer.Time);
return new ViewCell
{
View = new StackLayout
{
Children =
{
label
}
}
};
})
};
RelativeLayout rLayout = new RelativeLayout();
rLayout.Children.Add(lv,
xConstraint: Constraint.RelativeToParent((parent) =>
{
return (parent.Width/0.5) - 30;
}),
yConstraint: Constraint.RelativeToParent((parent) =>
{
return (parent.Height/-0.5) + 3;
}),
widthConstraint: Constraint.Constant(60),
heightConstraint: Constraint.RelativeToParent((Parent) =>
{
return (Parent.Height/10);
})
);
Content = new StackLayout
{
Children = {
rLayout
}
};
我是新来的xamarin,可能是我走的路是错误的。如果是这样,请建议我正确的一个..但总的来说,我想要一个水平的listview只有数字作为项目,我想高度被包裹到内容。
请任何帮助,将提前可观..感谢..
对于这样的简单的场景我可能会使用'''内'。使用'ItemsSource'属性创建基于'StackLayout'的自定义控件。 –
也许你可以尝试使用[carousel view](https://blog.xamarin.com/flip-through-items-with-xamarin-forms-carouselview/)。不太确定它是否适合您的使用案例。 –
感谢您的回答@EgorGromadskiy它帮助我..对不起,最近的回复.. – user5598997