How to make the absolute layout height dynamic in xamarin forms?

I have a view where the delete tab is not coming properly. My delete tab should have dynamic size it should fill the Tiles properly. For that height of the tab should be dynamic. But I don't know how to make the height of absolute layout dynamic. As you can see in image

The delete tab is coming properly in small Tiles. But in larger tile the the delete tab is small because the height is fixed. As you can see in this image below

This is my code for the view.

<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:local="clr-namespace:DMI.Xip;assembly=DMI.Xip" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
   <local:Border Margin="1,1,8,8"  VerticalOptions="Fill" HorizontalOptions="FillAndExpand" >
      <AbsoluteLayout Padding="0,0,1,0">
      <Frame Padding="1" CornerRadius="0"  BackgroundColor="#979797">
         <StackLayout Spacing="10" BackgroundColor="#ebebeb">
            <Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Padding="10" ColumnSpacing="5">
               <Grid.RowDefinitions>
                  <RowDefinition Height="*" />
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="2*" />
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="*" />
                  <RowDefinition Height="*" />
               </Grid.RowDefinitions>
               <Label Grid.Row="0" Text="{Binding Path=RrCoRep, StringFormat='Name: {0}'}" Style="{StaticResource TileSubTitlePrimaryStyle}" TextColor="Black" HorizontalOptions="FillAndExpand" />
               <BoxView Grid.Row="1" HeightRequest="1" Color="#979797" />
               <StackLayout Grid.Row="2" Spacing="5" Orientation="Horizontal">
                  <StackLayout Orientation="Vertical">
                     <Label Text="{Binding Path=RrCoTitle, StringFormat='Title: {0}'}" Style="{StaticResource TileSubTitlePrimaryStyle}" TextColor="Black" HorizontalOptions="FillAndExpand" />
                     <Label Text="{Binding Path=RrCoEmail, StringFormat='Email: {0}'}" Style="{StaticResource TileSubTitlePrimaryStyle}" TextColor="Black" HorizontalOptions="FillAndExpand" LineBreakMode="TailTruncation" />
                  </StackLayout>
                  <StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand" WidthRequest="140" MinimumWidthRequest="140" Spacing="1" VerticalOptions="EndAndExpand">
                     <Label Text="{Binding Path=RrCoMobileNumber,StringFormat='Mobile: {0}'}" Style="{StaticResource TileSubTitlePrimaryStyle}" TextColor="Black" HorizontalOptions="StartAndExpand" VerticalOptions="EndAndExpand" Margin="0" />
                  </StackLayout>
               </StackLayout>
               <BoxView Grid.Row="3" HeightRequest="1" Color="#979797" />
               <Label Grid.Row="4" Text="Railroad/Company Name: " Style="{StaticResource TileSubTitlePrimaryStyle}" TextColor="Black" />
               <Label Grid.Row="5" Text="{Binding Path=RrCoName,Mode=TwoWay}" Style="{StaticResource TileSubTitlePrimaryStyle}" TextColor="Black" />
               <Label Grid.Row="4" Text="R/C: " Style="{StaticResource TileSubTitlePrimaryStyle}" TextColor="Black" HorizontalOptions="EndAndExpand" />
               <Label Grid.Row="5" Text="{Binding Path=RrCo,Mode=TwoWay}" Style="{StaticResource TileSubTitlePrimaryStyle}" TextColor="Black" HorizontalOptions="EndAndExpand" />
            </Grid>
         </StackLayout>
          </Frame>
         <StackLayout AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" BackgroundColor="LightGray" IsVisible="{Binding IsActionEnabled}" Opacity="0.4" />
         <Grid AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" BackgroundColor="#598EBF" HorizontalOptions="EndAndExpand" IsVisible="{Binding IsActionEnabled}" VerticalOptions="FillAndExpand" WidthRequest="80">
            <Grid.RowDefinitions>
               <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <StackLayout Grid.Row="0" Padding="5" Orientation="Vertical" VerticalOptions="Fill">
               <local:IconLabel FontSize="28" HorizontalTextAlignment="Center" IsVisible="{Binding IsDeleteAllowed}" Text="icon-trash" TextColor="White" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" />
            </StackLayout>
            <Grid.GestureRecognizers>
               <TapGestureRecognizer Command="{Binding DeleteCommand}" CommandParameter="{Binding .}" />
            </Grid.GestureRecognizers>
         </Grid>
      </AbsoluteLayout>
   </local:Border>
</ContentView>

I don't have any clue how to fix this. Any suggestions?

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    Can you please provide a sample to help me reproduce your issue on my side?

Sign In or Register to comment.