C# 如何使用xamarin在StackLayout中容纳5列而不离开框架
我想在StackLayout中将5列放在一起,而不离开框架。在iPhone12Pro Max中,一切正常,但在iPhone8中,情况看起来不太好 我的代码:C# 如何使用xamarin在StackLayout中容纳5列而不离开框架,c#,xamarin,C#,Xamarin,我想在StackLayout中将5列放在一起,而不离开框架。在iPhone12Pro Max中,一切正常,但在iPhone8中,情况看起来不太好 我的代码: <Frame BorderColor="White" Margin="10,0,10,0" CornerRadius="10"
<Frame
BorderColor="White"
Margin="10,0,10,0"
CornerRadius="10"
HasShadow="True"
BackgroundColor="Transparent">
<RelativeLayout>
<Image
x:Name="ImageDescriptionForecast1"
Aspect="AspectFill"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=1}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=1}"/>
<StackLayout>
<Label x:Name="DateTimeForecast1"
Style="{StaticResource labelStyle}"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center"
VerticalOptions="Center"
FontSize="14"/>
<Label x:Name="DateTimeForecast2"
Style="{StaticResource labelStyle}"
HorizontalTextAlignment="Center"
FontSize="14"/>
<Grid BackgroundColor="Transparent"
Padding="0,0,0,0"
RowSpacing="0"
ColumnSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
........
........
</Grid>
<StackLayout>
</RelativeLayout>
</Frame>
........
........
我试图在ColumnDefinition Width=“auto”上加上“auto”,但这对我不起作用。
有没有办法把它们放在显示屏上?当我们检查文档时,我们会发现
因此,当网格中项目的大小足够大时,即使我们将valueauto
设置为ColumnDefinition
,它也会占用大量空间
如果我们希望同一行中的项目占用相同的空间,我们通常为列定义设置*
。在这种情况下,如果一行有多个项目,并且单个项目占用大量空间,那么一行中的所有元素都不会完全显示在屏幕上
在这种情况下,我们需要调整项目的HeightRequest
和WidthRequest
例如:
<Frame Grid.Row="0"
HeightRequest="30" WidthRequest="30"
BackgroundColor="Yellow"
<Grid.Column="0">
<Image Source="watermelon.png" HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand" Aspect="AspectFill" />
</Frame>
s StackLayout将根据需要展开,以适合其子屏幕的大小。组装较小显示屏的5列的替代方案是什么?使用网格如何?等等,你在这么做。无论如何,将StackLayout父级更改为其他内容。StackLayout会根据需要展开。