You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 1, 2024. It is now read-only.
After updating to Xamarin.Forms SR15 or SR16, certain UI elements and dialogs do not properly resize if the application window size changes during runtime. This seems to be because the display size in the Android configuration object is not updated.
I found that this issue only occurs if you call CreateConfigurationContext(Configuration), but this was not an issue on older versions (and it is a fairly common technique to override some Android config values).
I suspect this may be an issue somewhere in Xamarin.Android but I experienced it in a Xamarin.Forms application after upgrading (likely because newer XF versions depend on newer Android binding libs).
Steps to Reproduce
Override AttachBaseContext in your Android MainActivity
Create a new configuration context (using CreateConfigurationContext) and pass it to the base implementation of AttachBaseContext
Run the app and attempt to resize the app window after it has loaded (freeform multi-window and split screen are the best for demonstrating this but even simply rotating will do)
Create some alert dialogs, use size triggers and/or inspect the screen size values from Context.Resources.Configuration or Xamarin.Forms.Device.Info.ScaledScreenSize (comparing before and after resizing)
OR
Download my simple repro app
Extract, build and run the app on an Android device
Resize the app window and watch for the alert dialog (it should trigger automatically on any app configuration change)
Add a breakpoint at the end of OnConfigurationChanged (in MainActivity) and evaluate the screen sizes in newConfig and currentConfig and compare them
Expected Behavior
Dialogs are sized to fit the display
The Height and Width values in Xamarin.Forms.Device.Info.ScaledScreenSize are updated to match the new window size
The ScreenHeightDp and ScreenWidthDp in Context.Resources.Configuration are updated to match the new window size
Actual Behavior
Dialogs are cropped if the display is sized significantly smaller than the original size on app startup (or dialogs are too small if the display is widened relative to the startup size)
Height and Width values in Xamarin.Forms.Device.Info.ScaledScreenSize do not update
ScreenHeightDp and ScreenWidthDp in Context.Resources.Configuration do not update (but the new config object passed on OnConfigurationChanged does hold the correctly updated values).
Basic Information
Version with issue: 5.0.02612 / 5.0.02622
Last known good version: 5.0.2578
Platform Target Frameworks:
Android: 33
Android Support Library / AndroidX Version: 1.9.0.3 (May affect earlier versions too but that is the minimum version required by these Xamarin.Forms versions)
Description
After updating to Xamarin.Forms SR15 or SR16, certain UI elements and dialogs do not properly resize if the application window size changes during runtime. This seems to be because the display size in the Android configuration object is not updated.
I found that this issue only occurs if you call CreateConfigurationContext(Configuration), but this was not an issue on older versions (and it is a fairly common technique to override some Android config values).
I suspect this may be an issue somewhere in Xamarin.Android but I experienced it in a Xamarin.Forms application after upgrading (likely because newer XF versions depend on newer Android binding libs).
Steps to Reproduce
OR
Expected Behavior
Actual Behavior
Basic Information
Screenshots
Reproduction Link
XamarinSizeBugRepro.zip
Workaround
Nothing yet besides removing the configuration overrides (but sometimes these are needed so this is not a good workaround in most cases).
The text was updated successfully, but these errors were encountered: