我想要水平滾動一些數字(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