dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.04k stars 1.73k forks source link

Grid Star in Android always full the screen #23445

Open albilaga opened 3 months ago

albilaga commented 3 months ago

Description

I have some view that I need to be adaptive sizes in content. This will be used in PopupPage. Imagine the layout like this

<Grid
            RowDefinitions="Auto,*,Auto"
            VerticalOptions="End">
            <Label Text="Title" />
            <ScrollView Grid.Row="1">
                <VerticalStackLayout Spacing="8">
                    <Image
                        HeightRequest="180"
                        WidthRequest="180" />
                    <VerticalStackLayout
                        HorizontalOptions="Center"
                        Spacing="8">
                        <BindableLayout.ItemTemplate>
                            <DataTemplate>
                                <Label Text="{Binding .}" />
                            </DataTemplate>
                        </BindableLayout.ItemTemplate>
                    </VerticalStackLayout>
                </VerticalStackLayout>
            </ScrollView>
            <Button
                Grid.Row="2"
                HorizontalOptions="Center"/>
        </Grid>

This is needed so I can have header and footer. But the content can be scrolled if the device screen is not enough (in case it is landscape)

This is working fine on iOS CleanShot 2024-07-05 at 11 41 29@2x

but on Android it force the content to be full of page CleanShot 2024-07-05 at 11 42 53@2x

Steps to Reproduce

  1. Open this repo https://github.com/albilaga/MauiIssues and run the project on Android and iOS
  2. Open the GridStarRowPage in iOS and Android. It will be look like above

Link to public reproduction project repository

https://github.com/albilaga/MauiIssues

Version with bug

8.0.61 SR6.1

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 11 and up

Did you find any workaround?

The workaround I can find right now is basically check if the content size height > screen height or not. If it is more than height then I should set the Grid.RowDefinitions[1]=GridLength.Star but if the content height < screen height then I should set Grid.RowDefinitions[1]=GridLengthAuto

The code is to work around is in here. Or when running from the repro project you can just uncomment this line

Relevant log output

No response

github-actions[bot] commented 3 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

kevinxufei commented 3 months ago

This issue has been verified using Visual Studio 17.11.0 Preview 2.1(8.0.61 & 8.0.40). Can repro on android platform with sample project.