@@ -14,6 +14,8 @@ public class MauiScrollView : UIScrollView, IUIViewLifeCycleEvents, ICrossPlatfo
1414 double _lastArrangeHeight ;
1515 double _lastArrangeWidth ;
1616
17+ UIUserInterfaceLayoutDirection ? _previousEffectiveUserInterfaceLayoutDirection ;
18+
1719 WeakReference < ICrossPlatformLayout > ? _crossPlatformLayoutReference ;
1820
1921 ICrossPlatformLayout ? ICrossPlatformLayoutBacking . CrossPlatformLayout
@@ -54,17 +56,24 @@ public override void LayoutSubviews()
5456 // For Right-To-Left (RTL) layouts, we need to adjust the content arrangement and offset
5557 // to ensure the content is correctly aligned and scrolled. This involves a second layout
5658 // arrangement with an adjusted starting point and recalculating the content offset.
57- if ( EffectiveUserInterfaceLayoutDirection == UIUserInterfaceLayoutDirection . RightToLeft )
58- {
59- var horizontalOffset = contentSize . Width - crossPlatformBounds . Width ;
60- crossPlatformLayout . CrossPlatformArrange ( new Rect ( new Point ( - horizontalOffset , 0 ) , crossPlatformBounds ) ) ;
61- ContentOffset = new CGPoint ( horizontalOffset , 0 ) ;
62- }
63- else
59+ if ( _previousEffectiveUserInterfaceLayoutDirection != EffectiveUserInterfaceLayoutDirection )
6460 {
65- ContentOffset = CGPoint . Empty ;
61+ if ( EffectiveUserInterfaceLayoutDirection == UIUserInterfaceLayoutDirection . RightToLeft )
62+ {
63+ var horizontalOffset = contentSize . Width - crossPlatformBounds . Width ;
64+ crossPlatformLayout . CrossPlatformArrange ( new Rect ( new Point ( - horizontalOffset , 0 ) , crossPlatformBounds ) ) ;
65+ ContentOffset = new CGPoint ( horizontalOffset , 0 ) ;
66+ }
67+ else
68+ {
69+ ContentOffset = CGPoint . Empty ;
70+ }
6671 }
6772
73+ // When switching between LTR and RTL, we need to re-arrange and offset content exactly once
74+ // to avoid cumulative shifts or incorrect offsets on subsequent layouts.
75+ _previousEffectiveUserInterfaceLayoutDirection = EffectiveUserInterfaceLayoutDirection ;
76+
6877 // When the content size changes, we need to adjust the scrollable area size so that the content can fit in it.
6978 if ( ContentSize != contentSize )
7079 {
0 commit comments