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; 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 (Context.TargetSdkVersion() < 17 && !_checkedForRtlScroll && _hScrollView != null && Element is IVisualElementController controller && controller.EffectiveFlowDirection.IsRightToLeft()) { _hScrollView.ScrollX = _container.MeasuredWidth - _hScrollView.MeasuredWidth - _hScrollView.ScrollX; } _checkedForRtlScroll = true; }
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; 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(); } }