Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Android 4th row of Grid not rendering #1950

Closed
PureWeen opened this issue Aug 4, 2021 · 4 comments
Closed

[Bug] Android 4th row of Grid not rendering #1950

PureWeen opened this issue Aug 4, 2021 · 4 comments
Assignees

Comments

@PureWeen
Copy link
Member

PureWeen commented Aug 4, 2021

Steps to Reproduce

Using the following XAML taken from here (this renderers fine on XF)
https://github.com/rachelkang/recipeSearch/blob/maui/WhatToEat/Views/StartingPage.xaml#L30

<Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="4.5*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="4.5*" />
        </Grid.RowDefinitions>
        <ScrollView Grid.Column="0" Grid.Row="1" Orientation="Horizontal" Margin="0,0,0,10">
            <StackLayout Orientation="Horizontal" Spacing="10" Padding="0,5">
                <Button Text="Rabbits"></Button>
                <Button Text="Rabbits1"></Button>
                <Button Text="Rabbits2"></Button>
                <Button Text="Rabbits3"></Button>
                <Button Text="Rabbits4"></Button>
                <Button Text="Rabbits5"></Button>
                <Button Text="Rabbits"></Button>
                <Button Text="Rabbits1"></Button>
                <Button Text="Rabbits2"></Button>
                <Button Text="Rabbits3"></Button>
                <Button Text="Rabbits4"></Button>
                <Button Text="Rabbits5"></Button>
            </StackLayout>
        </ScrollView>
        <Label Grid.Column="0" Grid.Row="2" Text="Search by diet" TextColor="Black" FontAttributes="Bold" FontSize="20"/>
        <ScrollView Grid.Column="0" Grid.Row="3" Orientation="Horizontal" Background="Green">
            <StackLayout Orientation="Horizontal" Background="Purple">
                <Button Text="Rabbits"></Button>
                <Button Text="Rabbits1"></Button>
                <Button Text="Rabbits2"></Button>
                <Button Text="Rabbits3"></Button>
                <Button Text="Rabbits4"></Button>
                <Button Text="Rabbits5"></Button>
                <Button Text="Rabbits"></Button>
                <Button Text="Rabbits1"></Button>
                <Button Text="Rabbits2"></Button>
                <Button Text="Rabbits3"></Button>
                <Button Text="Rabbits4"></Button>
                <Button Text="Rabbits5"></Button>
            </StackLayout>
        </ScrollView>
    </Grid>

You'll notice that the 4th row doesn't render any content. I also tried removing the ScrollView but the result is the same

Expected Behavior

Their should be two rows of buttons

Actual Behavior

There is only one row of buttons

@PureWeen PureWeen changed the title [Bug] 4th row of Grid not rendering [Bug] Android 4th row of Grid not rendering Aug 4, 2021
@mattleibow
Copy link
Member

I think you are maybe missing the fact that rows are 0 index? You have rows for 1, 2, and 3 and thus have an empty row above?
image

@hartez
Copy link
Contributor

hartez commented Aug 5, 2021

The markup is weird because of the skipped row, but it should still be rendering the StackLayout inside the last ScrollView. The ScrollView is showing up (it's the green).

@hartez
Copy link
Contributor

hartez commented Aug 5, 2021

It's not a GridLayout issue - I can get a similar failure by doing this:

<VerticalStackLayout>
    <ScrollView Orientation="Horizontal" Background="LightBlue">
        <StackLayout Orientation="Horizontal" Background="Coral">
            <Button Text="Rabbits"></Button>
            ...
            <Button Text="Rabbits5"></Button>
        </StackLayout>
    </ScrollView>

    <ScrollView Orientation="Horizontal" Background="Green">
        <StackLayout Orientation="Horizontal" Background="Purple">
            <Button Text="Rabbits"></Button>
          ...
            <Button Text="Rabbits5"></Button>
        </StackLayout>
    </ScrollView>
</VerticalStackLayout>

So I'm guessing it's more of a ScrollView issue.

mattleibow added a commit that referenced this issue Aug 5, 2021
@mattleibow
Copy link
Member

I can get the buttons to appear correctly if I use the correct coordinates for the nested scrollview:

https://github.com/dotnet/maui/blob/6.0.100-preview.7/src/Core/src/Platform/Android/MauiScrollView.cs#L190

_hScrollView.Layout(0, 0, right - left, bottom - top);

However, this does not fully fix the issue as the child view is not actually getting to the correct size and the width is the width of the scrollview. If I set a WidthRequest to some big number then scrolling works.

Redth pushed a commit that referenced this issue Aug 5, 2021
@mattleibow mattleibow added this to the 6.0.100-preview.7 milestone Aug 5, 2021
Redth added a commit that referenced this issue Aug 5, 2021
* Clamp Grid coordinates for child views (#1947)

* Clamp Grid coordinates

* Use correct values

* bad coments

* Add span tests

* Add VisualDiagnostics calls to new Layout base (#1948)

* Lay out the nested scroll view correctly (#1952)

Might fix #1950

* Add VisualDiagnostics calls to new Layout base (#1948) (#1954)

Co-authored-by: E.Z. Hart <hartez@users.noreply.github.com>

Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
Co-authored-by: E.Z. Hart <hartez@users.noreply.github.com>
@ghost ghost locked as resolved and limited conversation to collaborators Feb 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants