protected override void OnLayout(bool changed, int left, int top, int right, int bottom) { // If the scroll view has changed size because of soft keyboard dismissal // (while WindowSoftInputModeAdjust is set to Resize), then we may need to request a // layout of the ScrollViewContainer bool requestContainerLayout = bottom > _previousBottom; _previousBottom = bottom; _container?.Measure(MeasureSpecFactory.MakeMeasureSpec(right - left, MeasureSpecMode.Unspecified), MeasureSpecFactory.MakeMeasureSpec(bottom - top, MeasureSpecMode.Unspecified)); base.OnLayout(changed, left, top, right, bottom); if (_view.Content != null && _hScrollView != null) { _hScrollView.Layout(0, 0, right - left, Math.Max(bottom - top, (int)Context.ToPixels(_view.Content.Height))); } else if (_view.Content != null && requestContainerLayout) { _container?.RequestLayout(); } // if the target sdk >= 17 then setting the LayoutDirection on the scroll view natively takes care of the scroll if (!_checkedForRtlScroll && _hScrollView != null && Element is IVisualElementController controller && controller.EffectiveFlowDirection.IsRightToLeft()) { Device.BeginInvokeOnMainThread(() => UpdateScrollPosition(_hScrollView.ScrollX, ScrollY)); } _checkedForRtlScroll = true; }