Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Xamarin: Grid in AbsoluteLayout not fill screen

I have an absolutLayout containing a grid. The absoluteLayout, as seen from the image, correctly fills the screen horizontally. The issue seems to be the grid, which is not drawn for the entire horizontal length of the screen, leaving an empty section. If I try to move the grid outside the absoluteLayout, the grid correctly fills the screen horizontally, so I think the problem is related to the absoluteLayout + grid combination.
I know very little about absoluteLayouts and I don’t understand how to solve this issue.

enter image description here

Xaml (to make it easy I have omitted the code for drawing the elements contained in the grid):

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

            <AbsoluteLayout BackgroundColor="Red">
            <Grid x:Name="GridDettaglio" Padding="4,2" ColumnSpacing="1" BackgroundColor="Aqua" HorizontalOptions="Fill" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="70"/>    <!--0-->
                    <ColumnDefinition Width="30"/>    <!--1-->
                    <ColumnDefinition Width="70"/>    <!--2-->
                    <ColumnDefinition Width="40"/>    <!--3-->
                    <ColumnDefinition Width="70"/>    <!--4-->
                    <ColumnDefinition Width="30"/>    <!--5-->
                    <ColumnDefinition Width="*"/>     <!--6-->
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/> 
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
              
            </Grid>
        </AbsoluteLayout>

>Solution :

I am not sure why are you using absolutelayout but for it to fill the screen you usually dont need to give it anything but since its not doing it on its own just give it the flags and bounds like below:

<Grid AbsoluteLayout.LayoutBounds="0,0,1,1"
             AbsoluteLayout.LayoutFlags="All" 

Goodluck feel free to get back if you have queries.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading