[Android] Layout changes are not rendered without triggering a render cycle via interaction with UI #10539
Labels
area-layout
StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter
platform/android 🤖
s/triaged
Issue has been reviewed
s/verified
Verified / Reproducible Issue ready for Engineering Triage
t/bug
Something isn't working
Milestone
Description
I have a layout that I am optimizing for Portrait and Landscape modes respectively.
When I rotate the device, I change some layout values, such as the
HorizontalOptions
andVerticalOptions
of certain Views that I would like to reposition in response to the size change for which I have an overide ofOnSizeAllocated()
. I am using the VisualStateManager to update the layout, but I've encountered exactly the same issue when I manually set the values in the code-behind or via bindings.The problem is that there seems to be a render cycle missing after updating the layout. The changes only get applied when I add some UI interaction, such as a button press that triggers a PropertyChanged event on some property. This problem applies to all kinds of Views, such as Grids, StackLayouts, Labels and Buttons.
In the following example to reproduce the issue, there is a button that is centered at the bottom in Portrait mode and moved to the right hand-side when going into Landscape mode. The button only changes its position after pressing it instead of updating immediately:
XAML
Code-behind
Note: This only occurs on Android, on iOS it works fine. This happens with real devices, not tested with emulators. I can reproduce this on Samsung S22 and S10 devices (at least).
Steps to Reproduce
Expected Behavior: The Button moves to the right in Landscape mode
Actual Behavior: The Button stays where it is and only updates its position after pressing it
Link to public reproduction project repository
https://github.com/ewerspej/dotnet-maui-bug-view-update
Version with bug
7.0.0-rc.1.22426.10
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 12.0
Did you find any workaround?
No
Relevant log output
No response
The text was updated successfully, but these errors were encountered: