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.26k stars 1.76k forks source link

StackLayout inside Scrollview with horizontal orientation not expanding #25462

Open letscodewithkalyan opened 1 month ago

letscodewithkalyan commented 1 month ago

Description

When we add stack layout with horizontal orientation to Scrollview with Horizontal orientation StackLayout horizontal options Fill is not working

Steps to Reproduce

  1. Added below code in project
  1. Expect Green Color in screen But Showing Yellow colour

Link to public reproduction project repository

https://github.com/letscodewithkalyan/MauiStackLayoutIssue

Version with bug

9.0.0-rc.2.24503.2

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

No response

Affected platforms

Android

Affected platform versions

Android

Did you find any workaround?

No response

Relevant log output

No response

ninachen03 commented 1 month ago

I can't see the code you provided. Could you provide us with a sample project so we can investigate it further? Looking forward to your reply!

PureWeen commented 1 month ago

Duplicate of #24078

michiel-nwa commented 4 weeks ago

@PureWeen I don't think this is the same issue. This happens without any CollectionView being involved.

Same issue also happens with FlexLayout and Grid in a horizontal ScrollView.

e.g.

<ScrollView BackgroundColor="Blue" HorizontalOptions="Fill" Orientation="Horizontal">
    <StackLayout Orientation="Horizontal" BackgroundColor="Green"  HorizontalOptions="Fill">
        <Label Text="A" BackgroundColor="Aqua"  />
        <Label Text="B" BackgroundColor="Red" />
    </StackLayout>
</ScrollView>

and

 <ScrollView BackgroundColor="Blue" HorizontalOptions="Fill" Orientation="Horizontal">
    <FlexLayout Direction="Row" BackgroundColor="Green"  HorizontalOptions="Fill">
        <Label FlexLayout.Basis="100" Text="A" BackgroundColor="Aqua" FlexLayout.Grow="1"  />
        <Label FlexLayout.Basis="100" Text="B" BackgroundColor="Red" FlexLayout.Grow="1" />
    </FlexLayout>
</ScrollView>

This works fine on iOS (both stretch to full width there) but not on Android. (Even setting HorizontalOptions to FillAndExpand doesn't resolve it)

michiel-nwa commented 4 weeks ago

Workaround for now: Set scrollView.Content.MinimumWidthRequest to scrollView.Width whenever the size or Content changes.

letscodewithkalyan commented 3 weeks ago

@PureWeen @ninachen03 Here is GitHub link for reproduce issue in Maui https://github.com/letscodewithkalyan/MauiStackLayoutIssue

letscodewithkalyan commented 3 weeks ago

@samhouts @PureWeen Can you check below repo for issue reproduction and reopen the issue and provide any workaround. https://github.com/letscodewithkalyan/MauiStackLayoutIssue

Zhanglirong-Winnie commented 2 weeks ago

This issue has been verified using Visual Studio 17.12.0 Preview 5 (9.0.0-rc.2.24503.2 & 8.0.92 & 8.0.3). Can repro this issue on android platform. iOS: iImage Android: Image