From 5df78b97113d8c2ea30a50839fc7f3fc30d2491c Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Tue, 28 Aug 2018 17:05:25 -0600 Subject: [PATCH] [Android] fixes #3675 - set initial ScrollView Scroll values when RTL (#3676) --- .../Renderers/ScrollViewRenderer.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs index 90046b491..933c02185 100644 --- a/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs +++ b/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs @@ -252,8 +252,13 @@ namespace Xamarin.Forms.Platform.Android _container?.RequestLayout(); // if the target sdk >= 17 then setting the LayoutDirection on the scroll view natively takes care of the scroll - if (Context.TargetSdkVersion() < 17 && !_checkedForRtlScroll && _hScrollView != null && Element is IVisualElementController controller && controller.EffectiveFlowDirection.IsRightToLeft()) - _hScrollView.ScrollX = _container.MeasuredWidth - _hScrollView.MeasuredWidth - _hScrollView.ScrollX; + if (!_checkedForRtlScroll && _hScrollView != null && Element is IVisualElementController controller && controller.EffectiveFlowDirection.IsRightToLeft()) + { + if (Context.TargetSdkVersion() < 17) + _hScrollView.ScrollX = _container.MeasuredWidth - _hScrollView.MeasuredWidth - _hScrollView.ScrollX; + else + Device.BeginInvokeOnMainThread(() => UpdateScrollPosition(_hScrollView.ScrollX, ScrollY)); + } _checkedForRtlScroll = true; }