我在Android和iOS平台上都运行了该程序,您可以检查iOS上的组件是否在上面,并且我想以Android上的组件为中心,即在不影响Android的情况下进行调整。
我要修改网格值
<Grid RowSpacing="0">
<OnPlatform x:TypeArguments="Thickness">
<On Platform="Android">0,10,0,0</On>
<On Platform="iOS">0,20,0,0</On>
</OnPlatform>
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="60" />
<RowDefinition Height="280" />
</Grid.RowDefinitions>
<StackLayout Grid.Row="0" Orientation="Horizontal" Margin="30,0,30,0">
<local1:Submenu></local1:Submenu>
</StackLayout>
<Label Grid.Row="1" Text="Início" TextColor="White" FontSize="40" Margin="55,10,0,0"></Label>
<Grid Grid.Row="2" ColumnSpacing="5" RowSpacing="5" HorizontalOptions="Center" VerticalOptions="Center" Margin="48,20,48,0" >
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- button images -->
<Image x:Name="CmdCalendario" Grid.Row="0" Grid.Column="0" Source="calendarioFiscallivre.png" />
<Image x:Name="CmdContaCorrente" Grid.Row="0" Grid.Column="1" Source="botaocadastrolivre.png" />
<Image x:Name="CmdCadastro" Grid.Row="1" Grid.Column="0" Source="botaocadastrolivre.png" />
<Image x:Name="CmdOutros" Grid.Row="1" Grid.Column="1" Source="botaocadastrolivre.png"/>
<!--<Image x:Name="CmdLiquidacao" Grid.Row="1" Grid.Column="0" Source="botaocadastrolivre.png" />-->
</Grid>
</Grid>
我也从后面的代码中进行了测试,但是它不起作用
switch (Device.RuntimePlatform)
{
case Device.iOS:
grid.RowDefinitions.Add(new RowDefinition { Height = 130 });
grid.RowDefinitions.Add(new RowDefinition { Height = 80 });
grid.RowDefinitions.Add(new RowDefinition { Height = 250 });
break;
case Device.Android:
grid.RowDefinitions.Add(new RowDefinition { Height = 100 });
grid.RowDefinitions.Add(new RowDefinition { Height = 80 });
grid.RowDefinitions.Add(new RowDefinition { Height = 280 });
break;
}
答案 0 :(得分:0)
尝试在Thickness
属性下指定Grid.Padding
。Thickness
是Padding
属性的类型。
解决方案:
<Grid.Padding>
<OnPlatform x:TypeArguments="Thickness">
<On Platform="Android">0,10,0,0</On>
<On Platform="iOS">0,20,0,0</On>
</OnPlatform>
</Grid.Padding>