Fix Android ScrollView to Measure Content Correct #30997
Merged
+0
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
This PR is a re-application of #30964 to make sure that @kubaflo is added as a co-author
This pull request introduces several updates to the
ScrollViewand its related components to improve layout handling, measurement logic, and platform-specific implementation for Android. The changes focus on simplifying code, enhancing functionality, and addressing edge cases in layout and measurement.Enhancements to measurement and layout logic:
ICrossPlatformLayout.CrossPlatformMeasureandCrossPlatformArrange: Improved measurement logic by introducing explicit constraints based on scroll orientation and utilizing the newMeasureContentmethod for more accurate content measurement. Added null checks and default values to prevent errors during layout operations. ([[1]](https://github.com/dotnet/maui/pull/30997/files#diff-d3dcb79b77b66e99d195c7e8406a19b95224604786bab4e82509c4acd3913735L246-R266),[[2]](https://github.com/dotnet/maui/pull/30997/files#diff-d3dcb79b77b66e99d195c7e8406a19b95224604786bab4e82509c4acd3913735L237-R238))MeasureContentmethod inLayoutExtensions: Added a new internal method to handle content measurement with support for explicit dimensions and padding adjustments, improving modularity and reusability. ([src/Core/src/Layouts/LayoutExtensions.csR170-R200](https://github.com/dotnet/maui/pull/30997/files#diff-923a4005b8fd76c6fe5a26814219f9002063666b6d6a49b6b1e19aea086628f4R170-R200))Platform-specific updates for Android:
MauiHorizontalScrollViewinitialization: Enabled theFillViewportproperty to ensure the scroll view fills its viewport, enhancing usability for horizontal scrolling. ([src/Core/src/Platform/Android/MauiScrollView.csL100-R104](https://github.com/dotnet/maui/pull/30997/files#diff-546ef8b25e238ce6a1820c920cb327471d6481eefc486eae39b3e5a31b45d907L100-R104))CrossPlatformArrangelogic: Simplified the layout handling inMauiScrollViewby removing theCrossPlatformArrangeproperty and related code, which was no longer required. ([[1]](https://github.com/dotnet/maui/pull/30997/files#diff-546ef8b25e238ce6a1820c920cb327471d6481eefc486eae39b3e5a31b45d907L232-L240),[[2]](https://github.com/dotnet/maui/pull/30997/files#diff-546ef8b25e238ce6a1820c920cb327471d6481eefc486eae39b3e5a31b45d907L324-L325))Code cleanup and refactoring:
ScrollViewandScrollViewHandler.Android: Adjusted formatting and removed redundant code to enhance clarity and maintainability. ([[1]](https://github.com/dotnet/maui/pull/30997/files#diff-7c61a3f8442182cb2e772edaa805382c721965440aa3b0244462d1aae6c4ee4dL518-R519),[[2]](https://github.com/dotnet/maui/pull/30997/files#diff-d3dcb79b77b66e99d195c7e8406a19b95224604786bab4e82509c4acd3913735L28-L35))Issues Fixed
Fixes #30951