I am using collection view in Xamarin and I don't know what reason the scrolling is not smooth. I implemented compiled binding and increased the Garbage collector size in android. I would like any recommendation on how to optimize the collection view, or point out what the problem is.
<CollectionView x:DataType="viewmodels:PageViewModel" ItemsSource="{Binding ItemList}" >
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="models:Item">
<StackLayout>
<BoxView HorizontalOptions="FillAndExpand" HeightRequest="5" Color="Silver"/>
<Grid RowSpacing="0" ColumnSpacing="0" Padding="15,10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackLayout Grid.Row="0" Grid.ColumnSpan="2" Grid.Column="0" Orientation="Horizontal">
<ff:CachedImage Source="Image.jpg" HeightRequest="50" WidthRequest="50" HorizontalOptions="Start">
<ff:CachedImage.Transformations>
<ffTrans:CircleTransformation />
</ff:CachedImage.Transformations>
</ff:CachedImage>
<StackLayout HorizontalOptions="FillAndExpand" Padding="10,0,0,0">
<Label Text="{Binding Name}" FontSize="Small"/>
<Label Text="{Binding Date, StringFormat='{0:dd MMM yyyy}'}" FontSize="Small"/>
</StackLayout>
</StackLayout>
<ImageButton Grid.Row="0" BackgroundColor="Transparent" Grid.Column="2" IsVisible="True" Source="Icon.png" WidthRequest="30" HorizontalOptions="End">
<ImageButton.Triggers>
<DataTrigger TargetType="ImageButton" Binding="{Binding .}" Value="True" >
<Setter Property="IsVisible" Value="False" />
</DataTrigger>
<DataTrigger TargetType="ImageButton" Binding="{Binding .}" Value="False" >
<Setter Property="IsVisible" Value="False" />
</DataTrigger>
</ImageButton.Triggers>
</ImageButton>
<ImageButton Grid.Row="0" BackgroundColor="Transparent" Grid.Column="2" IsVisible="False" Source="Icon.png" WidthRequest="30" HorizontalOptions="End">
<ImageButton.Triggers>
<DataTrigger TargetType="ImageButton" Binding="{Binding .}" Value="True" >
<Setter Property="IsVisible" Value="True" />
</DataTrigger>
</ImageButton.Triggers>
</ImageButton>
<ImageButton Grid.Row="0" BackgroundColor="Transparent" Grid.Column="2" IsVisible="False" Source="img.png" WidthRequest="30" HorizontalOptions="End">
<ImageButton.Triggers>
<DataTrigger TargetType="ImageButton" Binding="{Binding .}" Value="False" >
<Setter Property="IsVisible" Value="True" />
</DataTrigger>
</ImageButton.Triggers>
</ImageButton>
<ImageButton Grid.Row="0" BackgroundColor="Transparent" Grid.Column="2" Source="Icon.png" WidthRequest="20" HorizontalOptions="Center"/>
<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Text="{Binding Text}" Margin="0,10"/>
<mediavideoplayer:VideoPlayer x:Name="mediaelement" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" IsEnabled="{Binding Attachments, Converter={StaticResource VideoVisibilityConverter}}" IsVisible="{Binding Attachments ,Converter={StaticResource VideoVisibilityConverter}}" DisplayControls="False" FillMode="ResizeAspectFill" HeightRequest="350" AutoPlay="True" Repeat="True">
<mediavideoplayer:VideoPlayer.Source>
<MultiBinding Converter="{StaticResource VideoUrlConverter}">
<Binding Path="Attachments.Path" />
<Binding Path="Attachments" />
</MultiBinding>
</mediavideoplayer:VideoPlayer.Source>
</mediavideoplayer:VideoPlayer>
<Image IsVisible="{Binding Attachments, Converter={StaticResource ImageVisibilityConverter}}" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" Aspect="AspectFill" Style="{StaticResource StCommentPicture}">
<Image.Source>
<MultiBinding Converter="{StaticResource UrlConverter}">
<Binding Path="Attachments.path" />
<Binding Path="Attachments" />
</MultiBinding>
</Image.Source>
</Image>
<StackLayout Grid.Row="3" Grid.Column="0" >
<Label Text="👍" />
<Label Text="😍" />
<Label Text="😂" />
<Label x:Name="LikesCount" Grid.Row="5" Grid.Column="1" Text="{Binding likes}" />
</StackLayout>
<Label Grid.Row="3" Grid.Column="2" HorizontalOptions="End" Text="{Binding Comments, StringFormat='{0} Comments'}" Margin="0,6"/>
<BoxView Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="3" VerticalOptions="EndAndExpand" HeightRequest="1" Color="LightGray" Margin ="0,5"/>
<Frame Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" x:Name="likeArea" Opacity="0" Padding="0" HasShadow="true" OutlineColor="#EEEEEE" CornerRadius="70">
<Grid x:Name="GridlikeArea" Padding="5,0" BackgroundColor="Transparent" ColumnDefinitions="*,*,*,*,*" VerticalOptions="CenterAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<ImageButton x:Uid="Like" BackgroundColor="Transparent" Grid.Row="0" Grid.Column="0" Aspect="AspectFit" Source="Like.png" Clicked="LikeFrame_Clicked" ></ImageButton>
<ImageButton x:Name="Laugh" BackgroundColor="Transparent" Grid.Row="0" Grid.Column="1" Aspect="AspectFit" Source="Laugh.png" Clicked="LikeFrame_Clicked"></ImageButton>
<ImageButton x:Name="Love" BackgroundColor="Transparent" Grid.Row="0" Grid.Column="2" Aspect="AspectFit" Source="love.png" Clicked="LikeFrame_Clicked"></ImageButton>
<ImageButton x:Name="Sad" BackgroundColor="Transparent" Grid.Row="0" Grid.Column="3" Aspect="AspectFit" Source="sad.png" Clicked="LikeFrame_Clicked"></ImageButton>
<ImageButton x:Name="Hate" BackgroundColor="Transparent" Grid.Row="0" Grid.Column="4" Aspect="AspectFit" Source="angry.png" Clicked="LikeFrame_Clicked"></ImageButton>
</Grid>
</Frame>
<Button x:Name="LikeButton" HeightRequest="40" BackgroundColor="{Binding Reactions,Converter={StaticResource ReactionColorConverter}}"
CornerRadius="50" Grid.Row="5" Grid.Column="0" ImageSource="{Binding Reactions, Converter={StaticResource ReactionImageConverter}}" Text="Like" Clicked="LikeButton_Clicked" HorizontalOptions="StartAndExpand"/>
</Grid>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
<CollectionView.Footer>
<StackLayout HorizontalOptions="CenterAndExpand" Padding="0">
<Button BackgroundColor="Transparent" HorizontalOptions="CenterAndExpand" TextColor="#529dff" FontAttributes="Bold" Text="Load More..." Command="{Binding LoadMoreCommand}" Clicked="loadmorebutton_Clicked"/>
</StackLayout>
</CollectionView.Footer>
</CollectionView>
**Note: deleting the mediavideoplayer:VideoPlayer control wont make any difference **
The Issue is solved by the nuget Glidex. glidex.forms is small library we can use to improve Xamarin.Forms image performance on Android by taking a dependency on Glide. See my post on the topic here.
Related
In the DataTemplate of a CollectionView I have a Grid, and inside it a Row to which I insert the Height value in Auto. I associate a Label with that Row, but it is not displayed, while if I insert an absolute value in the Row then the text is visible. How could I solve?
<CollectionView
RelativeLayout.YConstraint="{ConstraintExpression
Type=Constant,
Constant=140}"
RelativeLayout.WidthConstraint="{ConstraintExpression
Type=RelativeToParent,
Property=Width,
Factor=1}"
Margin="10,0">
<CollectionView.ItemsLayout>
<LinearItemsLayout Orientation="Vertical" ItemSpacing="9"/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<yummy:PancakeView CornerRadius="5">
<RelativeLayout>
<Grid BackgroundColor="LightGray" RowSpacing="0.2">
<Grid.RowDefinitions>
<RowDefinition Height="1"/>
<RowDefinition Height="16"/>
<RowDefinition Height="16"/>
<RowDefinition Height="25"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="65"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<BoxView Grid.ColumnSpan="2" Grid.Row="0" BackgroundColor="{Binding ColoreUmore}"/>
<Image Grid.Row="1" Grid.RowSpan="3" Grid.Column="0" Margin="8" Source="{Binding Umore}" VerticalOptions="Start"/>
<Label Grid.Row="1" Grid.Column="1" Text="{Binding GiornoTrascritto}" FontSize="14" TextColor="Black" Opacity="0.7" />
<Label Grid.Row="2" Grid.Column="1" Text="{Binding Orario}" FontSize="14" TextColor="Black" Opacity="0.7" />
<Label Grid.Row="3" Grid.Column="1" Text="{Binding DescrizioneUmore}" FontSize="16" TextColor="{Binding ColoreUmore}" HorizontalTextAlignment="Start"/>
<FlexLayout
Grid.Row="4"
Margin="0,5,10,0"
Grid.Column="1"
BindableLayout.ItemsSource="{Binding IconDiaries}"
Wrap="Wrap"
JustifyContent="Start"
Direction="Row"
AlignItems="Start"
AlignContent="Start">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Grid Padding="0,2,3,0">
<Grid.RowDefinitions>
<RowDefinition Height="17"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="18"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<BoxView BackgroundColor="Black" Opacity="0.4" Grid.ColumnSpan="2" Grid.Row="0" CornerRadius="5" />
<Image Grid.Row="0" Grid.Column="0" Source="{Binding isSource}" Margin="3"/>
<Label Grid.Row="0" Grid.Column="1" Text="{Binding id}" TextColor="{Binding ColoreUmore}" FontSize="12" VerticalTextAlignment="Center" Margin="0,0,3,0"/>
</Grid>
</DataTemplate>
</BindableLayout.ItemTemplate>
</FlexLayout>
<BoxView Grid.Row="5" Grid.Column="1" CornerRadius="7" BackgroundColor="Black" Opacity="0.2" Margin="0,0,4,4"/>
THIS-----> <Label Grid.Row="5" Grid.Column="1" TextColor="White" FontSize="16" Text="{Binding Nota}" Margin="5,0,9,0" />
<Image Source="rightArrowB" Grid.Row="1" Grid.Column="1" HorizontalOptions="End" Margin="0,0,10,0" Rotation="90" Opacity="0.4"/>
<Button Grid.Row="1" Grid.Column="1" WidthRequest="70" HeightRequest="21" BackgroundColor="Transparent" Clicked="BtOperazioni"/>
</Grid>
<StackLayout
RelativeLayout.YConstraint="{ConstraintExpression
Type=Constant,
Constant=8}"
RelativeLayout.XConstraint="{ConstraintExpression
Type=Constant,
Constant=200}"
HeightRequest="72"
WidthRequest="90"
IsVisible="{Binding Edit}">
<Button Text="Modifica" BackgroundColor="Blue" Opacity="0.9" CornerRadius="5" TextColor="White" HeightRequest="37" />
<Button Text="Elimina" BackgroundColor="Blue" Opacity="0.9" CornerRadius="5" TextColor="White" Clicked="EliminaDiario" HeightRequest="37" />
</StackLayout>
</RelativeLayout>
</yummy:PancakeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
Im' working on XAML view and I want to create simple view with left side bar and the content with Grid and inside grid I have some buttons, that I want to achieve is to fill all form
Code:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:App.ViewModels"
mc:Ignorable="d"
x:Class="App.Views.UserSelectionPage">
<ContentPage.Content>
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Vertical" BackgroundColor="#093145" HorizontalOptions="Start" VerticalOptions="FillAndExpand" >
<Label Text="AppName"
Grid.Row="0"
Grid.Column="1"
HorizontalOptions="Center"
VerticalOptions="Center"
FontSize="Header"
TextColor="White"
Margin="15,0,10,15" />
</StackLayout>
<StackLayout Orientation="Vertical" VerticalOptions="End" BackgroundColor="#093145">
<Image Source="Assets/LargeTitle.scale-100.png"
Grid.Row="0"
Grid.Column="0"
HorizontalOptions="Center"
WidthRequest="90"
HeightRequest="90"
Margin="15,0,10,15"
VerticalOptions="Center"/>
</StackLayout>
</StackLayout>
<Grid BackgroundColor="AliceBlue">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!--<BoxView Color="#505CA9" Grid.Row="0" Grid.ColumnSpan="3" />-->
<Button Text="Use username instead"
Command="{Binding ToggleNewUserCommand}"
Grid.Row="0"
Grid.Column="2"
VerticalOptions="Center"
HorizontalOptions="End"
BackgroundColor="Transparent"
FontSize="Title"
TextColor="White"
Margin="15,0,10,15"/>
<Button x:Name="userOne"
d:Text="GQ"
Text="{Binding UserSelectionList[0].Abbreviation}"
Command="{Binding ButtonSelectedCommand}"
CommandParameter="{x:Reference userOne}"
TextColor="White"
HorizontalOptions="Center"
VerticalOptions="Center"
BorderWidth="1"
FontSize="92"
CornerRadius="160"
HeightRequest="320"
WidthRequest="320"
Margin="0,40,0,40"
Grid.Row="1"
Grid.Column="0"
BackgroundColor="{Binding UserSelectionList[0].BackgroundColor}"
d:BackgroundColor="#093145"/>
<Button x:Name="userTwo"
d:Text="LR"
Text="{Binding UserSelectionList[1].Abbreviation}"
Command="{Binding ButtonSelectedCommand}"
CommandParameter="{x:Reference userTwo}"
TextColor="White"
HorizontalOptions="Center"
VerticalOptions="Center"
BorderWidth="1"
FontSize="92"
CornerRadius="160"
HeightRequest="320"
WidthRequest="320"
Margin="0,40,0,40"
Grid.Row="1"
Grid.Column="1"
BackgroundColor="{Binding UserSelectionList[1].BackgroundColor}"
d:BackgroundColor="#107896" />
<Button x:Name="userThree"
d:Text="AR"
Text="{Binding UserSelectionList[2].Abbreviation}"
Command="{Binding ButtonSelectedCommand}"
CommandParameter="{x:Reference userThree}"
TextColor="White"
HorizontalOptions="Center"
VerticalOptions="Center"
BorderWidth="1"
FontSize="92"
CornerRadius="160"
HeightRequest="320"
WidthRequest="320"
Margin="0,40,0,40"
Grid.Row="1"
Grid.Column="2"
BackgroundColor="{Binding UserSelectionList[2].BackgroundColor}"
d:BackgroundColor="#829356" />
<Button x:Name="userFour"
d:Text="RR"
Text="{Binding UserSelectionList[3].Abbreviation}"
Command="{Binding ButtonSelectedCommand}"
CommandParameter="{x:Reference userFour}"
TextColor="White"
HorizontalOptions="Center"
VerticalOptions="Center"
BorderWidth="1"
FontSize="92"
CornerRadius="160"
HeightRequest="320"
WidthRequest="320"
Grid.Row="2"
Grid.Column="0"
BackgroundColor="{Binding UserSelectionList[3].BackgroundColor}"
d:BackgroundColor="#EBC944" />
<Button x:Name="userFive"
d:Text="GQ"
Text="{Binding UserSelectionList[4].Abbreviation}"
Command="{Binding ButtonSelectedCommand}"
CommandParameter="{x:Reference userFive}"
TextColor="White"
HorizontalOptions="Center"
VerticalOptions="Center"
BorderWidth="1"
FontSize="92"
CornerRadius="160"
HeightRequest="320"
WidthRequest="320"
Grid.Row="2"
Grid.Column="1"
BackgroundColor="{Binding UserSelectionList[4].BackgroundColor}"
d:BackgroundColor="#F26D21" />
<Button x:Name="userSix"
d:Text="GQ"
Text="{Binding UserSelectionList[5].Abbreviation}"
CommandParameter="{x:Reference userSix}"
Command="{Binding ButtonSelectedCommand}"
TextColor="White"
HorizontalOptions="Center"
VerticalOptions="Center"
BorderWidth="1"
FontSize="92"
CornerRadius="160"
HeightRequest="320"
WidthRequest="320"
Grid.Row="2"
Grid.Column="2"
BackgroundColor="{Binding UserSelectionList[5].BackgroundColor}"
d:BackgroundColor="#C02F1D" />
</Grid>
</StackLayout>
</ContentPage.Content>
Problem is for some reason it has free space inclusive if I use FillAndExpand on main StackLayout
I read about that but people just say that I missing FillAndExpand, I think problem is because I use Orientation="Horizontal" into first StackLayout, but that is the way I found to merge side bar with gridview. How can I achieve this? Regards
Add HorizontalOptions to the Grid itself:
<Grid HorizontalOptions="FillAndExpand" BackgroundColor="AliceBlue">
I made a table with xamarin forms, but I would like the headers not to have blank spaces and also put borders, use table-striped, have the basic characteristics of a bootstrap table for example. Could you help me?. Thank you for you help.
Here my code.
<StackLayout BindingContext="{Binding OpportunityListViewModel}" Padding="8">
<ListView x:Name="ProposalListProduct"
ItemsSource="{Binding ProposalView}"
IsRefreshing="{Binding IsRefreshing}"
CachingStrategy="RecycleElement"
HasUnevenRows="True"
Margin="0">
<ListView.Header>
<Grid Margin="0" Padding="0" RowSpacing="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="10*" />
<ColumnDefinition Width="20*" />
<ColumnDefinition Width="20*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" Margin="0" Text="Item" FontSize="8" TextColor="Black" BackgroundColor="LightGray" HorizontalTextAlignment="Center" HorizontalOptions="Fill" />
<Label Grid.Row="0" Grid.Column="1" Margin="0" Text="Cant." FontSize="8" TextColor="Black" BackgroundColor="LightGray" HorizontalTextAlignment="Center" HorizontalOptions="Fill" />
<Label Grid.Row="0" Grid.Column="2" Margin="0" Text="Precio" FontSize="8" TextColor="Black" BackgroundColor="LightGray" HorizontalTextAlignment="Center" HorizontalOptions="Fill" />
<Label Grid.Row="0" Grid.Column="3" Margin="0" Text="Total" FontSize="8" TextColor="Black" BackgroundColor="LightGray" HorizontalTextAlignment="Center" HorizontalOptions="Fill" />
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Grid Margin="0" Padding="0" RowSpacing="0" ColumnSpacing="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="10*" />
<ColumnDefinition Width="20*" />
<ColumnDefinition Width="20*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20" />
</Grid.RowDefinitions>
<Label Grid.Column="0" Margin="0" x:Name="Nombre" Text="{Binding Nombre}" FontSize="8" TextColor="Black" VerticalTextAlignment="End" HorizontalTextAlignment="Start" />
<Label Grid.Column="1" Margin="0" x:Name="Cantidad" Text="{Binding Cantidad}" FontSize="8" TextColor="Black" VerticalTextAlignment="End" HorizontalTextAlignment="End"/>
<Label Grid.Column="2" Margin="0" x:Name="Precio" Text="{Binding Precio,StringFormat='{0:C2}'}" FontSize="8" TextColor="Black" VerticalTextAlignment="End" HorizontalTextAlignment="End"/>
<Label Grid.Column="3" Margin="0" x:Name="Total" Text="{Binding Total,StringFormat='{0:C2}'}" FontSize="8" TextColor="Black" VerticalTextAlignment="End" HorizontalTextAlignment="End"/>
</Grid>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
you can do it like this:
<ListView ItemsSource="{Binding People}"
HasUnevenRows="True"
SeparatorVisibility="None">
<ListView.Header>
<Frame>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label Text="Name"
HorizontalOptions="Center"
FontSize="Large"/>
<Label Grid.Column="1"
Text="Description"
HorizontalOptions="Center"
FontSize="Large"/>
<BoxView Grid.Row="1"
Grid.ColumnSpan="2"
HeightRequest="1"
BackgroundColor="LightGray"/>
</Grid>
</Frame>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Margin="20,10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label Text="{Binding Name}"
HorizontalOptions="Center"
VerticalOptions="Center"/>
<Label Grid.Column="1"
Text="{Binding Description}"
HorizontalOptions="Center"
VerticalOptions="Center"/>
<BoxView Grid.Row="1"
Grid.ColumnSpan="2"
HeightRequest="1"
BackgroundColor="LightGray"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
I have 4 buttons in the bottom part of the screen as menus and I had used grid to show 4 buttons with same width and height and will occupy the whole screen. I have these codes but the result is not they way i wanted. It is not occupying the whole screen. Please help me how can I achieve it. Thanks.
<AbsoluteLayout BackgroundColor="#BC3022" MinimumHeightRequest="20" Padding="0,10,10,10" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Grid ColumnSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<BoxView Grid.Row="0" Grid.Column="0"/>
<StackLayout Grid.Row="0" Grid.Column="0" Padding="10,2,10,2">
<Image Source="home.png" WidthRequest="40" HeightRequest="25"/>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Home</Label>
</StackLayout>
<BoxView Grid.Row="0" Grid.Column="1"/>
<StackLayout Grid.Row="0" Grid.Column="1" Padding="10,2,10,2">
<Image Source="jobs.png" WidthRequest="40" HeightRequest="25">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnJobsGestureTap" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Jobs</Label>
</StackLayout>
<BoxView Grid.Row="0" Grid.Column="2"/>
<StackLayout Grid.Row="0" Grid.Column="2" Padding="10,2,10,2">
<Image Source="sync.png" WidthRequest="40" HeightRequest="25"/>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Sync</Label>
</StackLayout>
<BoxView Grid.Row="0" Grid.Column="3"/>
<StackLayout Grid.Row="0" Grid.Column="3" Padding="10,2,10,2">
<Image Source="logout.png" WidthRequest="40" HeightRequest="25">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnLogoutGestureTap" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Signout</Label>
</StackLayout>
</Grid>
</AbsoluteLayout>
This is how it looks:
Try to replace your code with below code:
<StackLayout BackgroundColor="#BC3022" MinimumHeightRequest="20" Padding="10,10,10,10" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Grid ColumnSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25*" />
<ColumnDefinition Width="25*" />
<ColumnDefinition Width="25*" />
<ColumnDefinition Width="25*" />
</Grid.ColumnDefinitions>
<BoxView Grid.Row="0" Grid.Column="0"/>
<StackLayout Grid.Row="0" Grid.Column="0" Padding="10,2,10,2">
<Image Source="home.png" WidthRequest="40" HeightRequest="25"/>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Home</Label>
</StackLayout>
<BoxView Grid.Row="0" Grid.Column="1"/>
<StackLayout Grid.Row="0" Grid.Column="1" Padding="10,2,10,2">
<Image Source="jobs.png" WidthRequest="40" HeightRequest="25">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnJobsGestureTap" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Jobs</Label>
</StackLayout>
<BoxView Grid.Row="0" Grid.Column="2"/>
<StackLayout Grid.Row="0" Grid.Column="2" Padding="10,2,10,2">
<Image Source="sync.png" WidthRequest="40" HeightRequest="25"/>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Sync</Label>
</StackLayout>
<BoxView Grid.Row="0" Grid.Column="3"/>
<StackLayout Grid.Row="0" Grid.Column="3" Padding="10,2,10,2">
<Image Source="logout.png" WidthRequest="40" HeightRequest="25">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnLogoutGestureTap" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Signout</Label>
</StackLayout>
</Grid>
</StackLayout>
I am facing one issue in xamarin.forms. I am using GridView to make login page design so it can be change accordingly device height and width. I don't want scroll that page So I didn't put any ScrollView.
Xaml Design Code :-
<?xml version="1.0" encoding="utf-8" ?>
<custom:KeyboardResizingAwareContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="HRMS.Login.LoginPage"
BackgroundImage="login_bg.png"
xmlns:local="clr-namespace:HRMS;assembly=HRMS"
Title="{x:Static local:AppResources.TitleLogin}"
xmlns:custom="clr-namespace:HRMS.Login;assembly=HRMS">
<ContentPage.Padding>
<OnIdiom x:TypeArguments="Thickness" Phone="60,40,60,40" Tablet="120,100,120,100" />
</ContentPage.Padding>
<custom:KeyboardResizingAwareContentPage.Resources>
<ResourceDictionary>
<Style x:Key="SubTitleStyle" TargetType="Label">
<Setter Property="FontSize" Value="Small" />
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="TextColor" Value="White" />
</Style>
</ResourceDictionary>
</custom:KeyboardResizingAwareContentPage.Resources>
<custom:KeyboardResizingAwareContentPage.Content>
<AbsoluteLayout x:Name="AbsMain">
<Grid VerticalOptions="Center" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1">
<Grid.RowDefinitions>
<RowDefinition Height="35*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="6*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="6*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image x:Name="ImgLogo" Source="login_logo.png" HorizontalOptions="Center" Grid.Row="0"/>
<StackLayout Grid.Row="1">
<StackLayout.HeightRequest>
<OnIdiom x:TypeArguments="x:Double" Tablet="55" Phone="35" />
</StackLayout.HeightRequest>
</StackLayout>
<Frame OutlineColor="#DCDCDC"
HorizontalOptions="FillAndExpand" VerticalOptions="Center"
HasShadow="false" Padding="1"
Grid.Row="2"
BackgroundColor="White"
Margin="5,0,5,0">
<Frame.HeightRequest>
<OnIdiom x:TypeArguments="x:Double" Tablet="55" Phone="35" />
</Frame.HeightRequest>
<Frame.Content>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="9*"/>
</Grid.ColumnDefinitions>
<Image x:Name="ImgLoginName" Grid.Column="0" Source="ico_login_name.png"
HorizontalOptions="StartAndExpand" VerticalOptions="Center" Margin="5,0,0,0"/>
<StackLayout Grid.Column="1" VerticalOptions="Center">
<Entry x:Name="TxtUsername" TextColor="#f15a23"
Margin="5,0,0,0"
PlaceholderColor="#8c8c8c"
BackgroundColor="White"
Placeholder="{x:Static local:AppResources.PHEmployeeCode}" />
</StackLayout>
</Grid>
</Frame.Content>
</Frame>
<Frame OutlineColor="#DCDCDC"
HorizontalOptions="FillAndExpand" VerticalOptions="Center"
HasShadow="false" Padding="1"
Grid.Row="3"
BackgroundColor="White"
Margin="5,0,5,0">
<Frame.HeightRequest>
<OnIdiom x:TypeArguments="x:Double" Tablet="55" Phone="35" />
</Frame.HeightRequest>
<Frame.Content>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="9*"/>
</Grid.ColumnDefinitions>
<Image x:Name="ImgLoginPassword" Grid.Column="0" Source="ico_login_password.png"
HorizontalOptions="StartAndExpand" VerticalOptions="Center" Margin="5,0,0,0"/>
<StackLayout Grid.Column="1" VerticalOptions="Center">
<Entry x:Name="TxtPassword" IsPassword="True" TextColor="#f15a23"
PlaceholderColor="#8c8c8c"
Margin="5,0,0,0"
BackgroundColor="White"
Placeholder="{x:Static local:AppResources.PHPassword}" />
</StackLayout>
</Grid>
</Frame.Content>
</Frame>
<Label x:Name="LblForgotPassword" Grid.Row="4" Margin="5,0,5,0"
Text="Forgot Password?" TextColor="Black" HorizontalTextAlignment="End"/>
<Button x:Name="BtnLogin" Text="{x:Static local:AppResources.BLogin}" Clicked="LoginButton_Clicked"
Grid.Row="5" BackgroundColor="#f15a23" TextColor="White"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Button.HeightRequest>
<OnIdiom x:TypeArguments="x:Double" Tablet="55" Phone="45" />
</Button.HeightRequest>
</Button>
<Image x:Name="ImgOr" Grid.Row="6" HorizontalOptions="FillAndExpand"
Source="or.png" />
<Button x:Name="BtnUpdateDevicewithlogin" Text="{x:Static local:AppResources.BUpdateDevice}"
Clicked="UpdateDeviceWithLoginButton_Clicked" Grid.Row="7"
BackgroundColor="#f15a23" TextColor="White" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Button.HeightRequest>
<OnIdiom x:TypeArguments="x:Double" Tablet="55" Phone="45" />
</Button.HeightRequest>
</Button>
</Grid>
<ActivityIndicator x:Name="actIndicator2" Color="#f15a23" Opacity="2"
HeightRequest="50" WidthRequest="50" VerticalOptions="Center" HorizontalOptions="Center"
AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1" />
</AbsoluteLayout>
</custom:KeyboardResizingAwareContentPage.Content>
</custom:KeyboardResizingAwareContentPage>
I am using "KeyboardResizingAwareContentPage" page instead "ContentPage" because In ios Page is not set when keyboard is open. password field hide behind keyboard so users can not see whatever then typing. That's why I am using Render for content Page in IOs.
As Above images when I focus on username or password entry field two buttons are hide behind the keyboard. Client requirement is that at that time page should be scroll. How can I solve this problem? Is it possible through rendering? I am facing this issue in both the platform. (ios and android)
Even if you don't mean to scroll your page, use a ScrollView as the root of your Page, and put your grid in it.
This should fix it.