How can I change the layout on one platform without affecting the other

Multi tool use
up vote
0
down vote
favorite
I ran the program on both Android and iOS platforms, and you can check that the components on iOS are a little above and I would like to center as they are on Android ie adjust it without affecting Android.
I want to modify Grid values
<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>
I also tested from the back code and it is not working
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;
}
c# xaml xamarin.forms xamarin.ios xamarin.android
add a comment |
up vote
0
down vote
favorite
I ran the program on both Android and iOS platforms, and you can check that the components on iOS are a little above and I would like to center as they are on Android ie adjust it without affecting Android.
I want to modify Grid values
<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>
I also tested from the back code and it is not working
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;
}
c# xaml xamarin.forms xamarin.ios xamarin.android
Have you tried setting the margin/padding of the contents of the rows instead of the row heights?
– Tom
Nov 8 at 10:06
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I ran the program on both Android and iOS platforms, and you can check that the components on iOS are a little above and I would like to center as they are on Android ie adjust it without affecting Android.
I want to modify Grid values
<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>
I also tested from the back code and it is not working
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;
}
c# xaml xamarin.forms xamarin.ios xamarin.android
I ran the program on both Android and iOS platforms, and you can check that the components on iOS are a little above and I would like to center as they are on Android ie adjust it without affecting Android.
I want to modify Grid values
<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>
I also tested from the back code and it is not working
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;
}
c# xaml xamarin.forms xamarin.ios xamarin.android
c# xaml xamarin.forms xamarin.ios xamarin.android
asked Nov 8 at 9:26
amara
143
143
Have you tried setting the margin/padding of the contents of the rows instead of the row heights?
– Tom
Nov 8 at 10:06
add a comment |
Have you tried setting the margin/padding of the contents of the rows instead of the row heights?
– Tom
Nov 8 at 10:06
Have you tried setting the margin/padding of the contents of the rows instead of the row heights?
– Tom
Nov 8 at 10:06
Have you tried setting the margin/padding of the contents of the rows instead of the row heights?
– Tom
Nov 8 at 10:06
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Try to specify the Thickness
under Grid.Padding
property.Thickness
is the type of Padding
property.
Solution:
<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>
How can I get different sizes of height in the grid
– amara
17 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Try to specify the Thickness
under Grid.Padding
property.Thickness
is the type of Padding
property.
Solution:
<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>
How can I get different sizes of height in the grid
– amara
17 hours ago
add a comment |
up vote
0
down vote
Try to specify the Thickness
under Grid.Padding
property.Thickness
is the type of Padding
property.
Solution:
<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>
How can I get different sizes of height in the grid
– amara
17 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
Try to specify the Thickness
under Grid.Padding
property.Thickness
is the type of Padding
property.
Solution:
<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>
Try to specify the Thickness
under Grid.Padding
property.Thickness
is the type of Padding
property.
Solution:
<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>
answered Nov 9 at 6:48


jack Hua
1495
1495
How can I get different sizes of height in the grid
– amara
17 hours ago
add a comment |
How can I get different sizes of height in the grid
– amara
17 hours ago
How can I get different sizes of height in the grid
– amara
17 hours ago
How can I get different sizes of height in the grid
– amara
17 hours ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204783%2fhow-can-i-change-the-layout-on-one-platform-without-affecting-the-other%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
iF2,8Cl,J,iZaxyn8iaz
Have you tried setting the margin/padding of the contents of the rows instead of the row heights?
– Tom
Nov 8 at 10:06