-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Bug][Regression] StackLayout doesn't render correctly on Android Xamarin.Forms 5 #14918
Comments
This issue seems to be related: #14398 |
Probably same as #14569. |
I have the same problem. When I change IsVisible for controls in StackLayout (in combination with ScrollView) in run-time, or when I use lazily loaded controls, the height of the StackLayout is not always updated and the controls can end up outside the visible area of the screen. |
Hi @jfversluis, @davidortinau, |
Yes, please. This is very annoying problem. |
Unfortunately not :( of course feel free to poke around the Xamarin.Forms source to see if you can find more details as to why this might be happening while we get to this one. |
I am facing this issue when using scrollview in both ios and Android. This is a critical bug and happens randomly. I can't release any of my apps because we don't know how it'll behave. |
This is really a horrible bug. I have spent almost an hour looking for a workaround. I have tried calling ForceLayout on various controls, which helped me a few times in the past with similar Xamarin.Forms bugs, but unfortunately it does not help for this one. The only thing that helps a little is to add a transparent control to the end of the StackLayout. If the height of this transparent control is greater than a certain threshold then some, or all of the controls, which were invisible because of the bug, are shown. Something like this: <Grid IsVisible="{OnPlatform Android=true, Default=false}">
<BoxView BackgroundColor="Transparent" HeightRequest="300" IsVisible="{Binding AllowErrorReporting, Converter={StaticResource invertedBoolConverter}}" />
</Grid> The goal is to keep the height of the ScrollView content more or less the same on Android. This creates a blank space on some scenarios so the app will look ugly. But unfortunately, ugly but functional app can be sometimes still considered as a victory on Xamarin.Forms :-(. I really wish that the upcoming MAUI would not inherit all these bugs. |
Workaround: I have finally found something that works well for this issue. This workaround has been proposed originally for another ScrollView issue (#13597) but I have found out that it helps also for this issue. The workaround is to enclose the ScrollView into a ContentView. So instead of: <ScrollView>
<StackLayout>...</StackLayout>
</ScrollView> it should be: <ContentView>
<ScrollView>
<StackLayout>...</StackLayout>
</ScrollView>
</ContentView> It seems that ScrollView is buggy if it is the root element of the page. Adding a ContentView into the hierarchy prevents this. |
Thanks for letting us know @holecekp hopefully this will also be some hint in order to fix this! |
Hey everyone a PR (#15066) has been opened that looks like it might address this issue. Would someone (or of course multiple people preferably 😄) be able to grab the NuGet as described here and let us know if this fixes this issue? That will greatly speed up the review process. Besides verifying if this particular issue is fixed also be sure to check other scenarios in the same area to make sure that this fix doesn't accidentally has side-effects 🙂 Thanks! |
@jfversluis Hello. I have tested the PR and I confirm it fixed the issue for me. It is no longer necessary to use the ContentView workaround. I have tested on Android and UWP. |
Thanks so much @holecekp ! |
@jfversluis For me and the sample App attached above its also resolved. Thanks a lot! |
@jfversluis, well done. Looks good here too. |
This should be fixed by #15076 and part of SR10 |
Description
Items inside StackLayout get lost, whenever they are added after initial rendering. This issue only appears on Android and whenever the StackLayout renders outside the screen bounds.
Steps to Reproduce
Expected Behavior
Last item is visible.
Actual Behavior
Last item is not visible only the reserved space.
Basic Information
Environment
Show/Hide Visual Studio info
Build Logs
Screenshots
Reproduction Link
https://github.com/tritter/forms-stacklayout-bug
Workaround
No, unfortunately not, this project is just a demonstration. In our app we use multiple StackLayouts to accomplish an interactive form, which is not replaceable by a 'simple' ListView which does not have the problem. At the moment we're stuck at Xamarin Forms 4.8!
The text was updated successfully, but these errors were encountered: