如何Xamarin.Forms调整水平的ListView的大小? [英] How to adjust size of Horizontal ListView in Xamarin.Forms?
本文介绍了如何Xamarin.Forms调整水平的ListView的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看到该项和尝试,是的,滚动的方向变成水平。
I see this entry and try it, yes, scroll orientation becomes horizontal.
不过,视大小不调整观看的轮廓。
But, size of view is not adjust to view's outline.
结果是这样的:
我怎样才能调整,即使它被旋转的角度大小?
How can I adjust the size of view even if it is rotated?
推荐答案
您可以使用相对布局调整位置。这是我使用的是旋转垂直列表视图执行水平列表视图的XAML例如:
You can use a relative layout to adjust the position. This is a XAML example of a horizontal list view I implemented using a rotated vertical list view:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ExampleProject.SomePage" >
<ContentPage.Content>
<RelativeLayout>
<ListView x:Name="listView"
ItemsSource="{Binding ExampleList}"
RowHeight="120"
Rotation="270"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.5, Constant=-60}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=-0.5, Constant=60}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=Constant, Constant=120}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Label Rotation="90"
TranslationX="120" />
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<StackLayout
RelativeLayout.XConstraint="{ConstraintExpression Type=Constant, Constant=0}"
RelativeLayout.YConstraint="{ConstraintExpression Type=Constant, Constant=120}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-120}"
>
<!-- Some content below list view -->
</StackLayout>
</RelativeLayout>
</ContentPage.Content>
</ContentPage>
这应该iOS和Android上工作。
This should work on iOS and Android.
这篇关于如何Xamarin.Forms调整水平的ListView的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文