简体   繁体   中英

Alignment of ListView items in Xamarin.Forms

I have two informations on each item: place name and distance, I would like to list them side by side as a unique item but distance should to stay on the right and place name on the left. I did it using 2 listviews inside a horizontal Stack layout and seemed ok but when user selects some item the scroll appears and mess the look and the user is abble to scroll just places or distances, I cant allow that. Can anyone give me a suggestion?

You should use two labels instead of two list views. One label is for placename and another is for distance and put them in a StackLayout with Horizontal Orientation. Right and Left can be achieved by setting appropriate values to HorizontalOptions on each label.

<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
    <Label Text="Place Name" HorizontalOptions="StartAndExpand" />
    <Label Text="Distance" HorizontalOptions="End" />
</StackLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM