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











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;
}









share|improve this question






















  • Have you tried setting the margin/padding of the contents of the rows instead of the row heights?
    – Tom
    Nov 8 at 10:06















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;
}









share|improve this question






















  • Have you tried setting the margin/padding of the contents of the rows instead of the row heights?
    – Tom
    Nov 8 at 10:06













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;
}









share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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












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>





share|improve this answer





















  • How can I get different sizes of height in the grid
    – amara
    17 hours ago











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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
































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>





share|improve this answer





















  • How can I get different sizes of height in the grid
    – amara
    17 hours ago















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>





share|improve this answer





















  • How can I get different sizes of height in the grid
    – amara
    17 hours ago













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>





share|improve this answer












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>






share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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




















































































Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)