protected override void OnLayout(bool changed, int l, int t, int r, int b) { if (changed) { var activity = (FormsAppCompatActivity)Context; _modal.Layout(new Rectangle(0, 0, activity.FromPixels(r - l), activity.FromPixels(b - t))); _backgroundView.Layout(0, 0, r - l, b - t); } _renderer.UpdateLayout(); }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { if (_renderer == null) { return; } var width = _context.FromPixels(r - l); var height = _context.FromPixels(b - t); LayoutView(0, 0, width, height); _renderer.UpdateLayout(); }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { if (Content == null) { return; } var size = Context.FromPixels(r - l, b - t); Content.Element.Layout(new Rectangle(Point.Zero, size)); Content.UpdateLayout(); }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { Performance.Start(); double width = Context.FromPixels(r - l); double height = Context.FromPixels(b - t); Performance.Start("Element.Layout"); Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion(_view.Element, new Rectangle(0, 0, width, height)); Performance.Stop("Element.Layout"); _view.UpdateLayout(); Performance.Stop(); }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { if (IsEmpty) { return; } double width = Context.FromPixels(r - l); double height = Context.FromPixels(b - t); Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion(_renderer.Element, new Rectangle(0, 0, width, height)); _renderer.UpdateLayout(); }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { base.OnLayout(changed, l, t, r, b); var refreshViewContent = RefreshView?.Content; if (refreshViewContent == null) { return; } IVisualElementRenderer renderer = AppCompat.Platform.GetRenderer(refreshViewContent); renderer?.UpdateLayout(); }
protected override void OnLayout(bool changed, int left, int top, int right, int bottom) { if (_childView == null) { return; } IVisualElementRenderer renderer = Platform.GetRenderer(_childView); try { renderer.UpdateLayout(); } catch (Exception) { } }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { if (_childView == null) { return; } Rectangle bounds = GetBounds(_isFlyout, l, t, r, b); if (_isFlyout) { FlyoutPageController.FlyoutBounds = bounds; } else { FlyoutPageController.DetailBounds = bounds; } IVisualElementRenderer renderer = APlatform.GetRenderer(_childView); renderer?.UpdateLayout(); // If we're using a PageContainer (i.e., we've wrapped our contents in a Fragment), // Make sure that it gets laid out if (_pageContainer != null) { if (_isFlyout) { var controller = (IFlyoutPageController)_parent; var width = (int)Context.ToPixels(controller.FlyoutBounds.Width); // When the base class computes the size of the Flyout container, it starts at the top of the // screen and adds padding (_parent.FlyoutBounds.Top) to leave room for the status bar // When this container is laid out, it's already starting from the adjusted y value of the parent, // so we subtract _parent.FlyoutBounds.Top from our starting point (to get 0) and add it to the // bottom (so the flyout page stretches to the bottom of the screen) var height = (int)Context.ToPixels(controller.FlyoutBounds.Height + controller.FlyoutBounds.Top); _pageContainer.Layout(0, 0, width, height); } else { _pageContainer.Layout(l, t, r, b); } _pageContainer.Child.UpdateLayout(); } }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { base.OnLayout(changed, l, t, r, b); if (_footerViewRenderer != null) { double pageWidth = Context.FromPixels(ViewGroup.MeasuredWidth); double pageHeight = Context.FromPixels(ViewGroup.MeasuredHeight); VisualElement footerView = _footerViewRenderer.Element; SizeRequest sizeRequest = footerView.Measure(pageWidth, double.PositiveInfinity, MeasureFlags.IncludeMargins); double heightRequest = sizeRequest.Request.Height; footerView.Layout(new Rectangle(0, pageHeight - heightRequest, pageWidth, heightRequest)); _footerViewRenderer.UpdateLayout(); } }
public void LayoutView(double width, double height) { _width = width; _height = height; Context context; if (_renderer == null || !(_context.TryGetTarget(out context)) || !_renderer.View.IsAlive()) { return; } if (View == null) { var empty = MeasureSpecFactory.GetSize(0); _renderer.View.Measure(empty, empty); return; } var request = View.Measure(width, height, MeasureFlags.None); var layoutParams = NativeView.LayoutParameters; if (height == -1) { height = request.Request.Height; } if (width == -1) { width = request.Request.Width; } if (layoutParams.Width != LP.MatchParent) { layoutParams.Width = (int)context.ToPixels(width); } if (layoutParams.Height != LP.MatchParent) { layoutParams.Height = (int)context.ToPixels(height); } NativeView.LayoutParameters = layoutParams; View.Layout(new Rectangle(0, 0, width, height)); _renderer.UpdateLayout(); }
static void UpdateLayout(IEnumerable <Element> children) { foreach (Element element in children) { var visualElement = element as VisualElement; if (visualElement == null) { continue; } IVisualElementRenderer renderer = AppCompat.Platform.GetRenderer(visualElement); if (renderer == null && CompressedLayout.GetIsHeadless(visualElement)) { UpdateLayout(visualElement.LogicalChildren); } renderer?.UpdateLayout(); } }
protected override void OnLayout(bool changed, int left, int top, int right, int bottom) { if (Element == null) { return; } var children = ((IElementController)Element).LogicalChildren; for (var i = 0; i < children.Count; i++) { var visualElement = children[i] as VisualElement; if (visualElement == null) { continue; } IVisualElementRenderer renderer = Android.Platform.GetRenderer(visualElement); renderer?.UpdateLayout(); } }
private void addChildView(VisualElement childView) { IVisualElementRenderer renderer = Platform.GetRenderer(childView); if (renderer == null) { Platform.SetRenderer(childView, renderer = Platform.CreateRenderer(childView)); } if (renderer.ViewGroup.Parent != this) { if (renderer.ViewGroup.Parent != null) { renderer.ViewGroup.RemoveFromParent(); } AddView(renderer.ViewGroup); renderer.UpdateLayout(); } }
protected virtual void AddChildView(VisualElement childView) { IVisualElementRenderer renderer = Platform.GetRenderer(childView); if (renderer == null) { Platform.SetRenderer(childView, renderer = Platform.CreateRenderer(childView, Context)); } if (renderer.View.Parent != this) { if (renderer.View.Parent != null) { renderer.View.RemoveFromParent(); } SetDefaultBackgroundColor(renderer); AddView(renderer.View); renderer.UpdateLayout(); } }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { if (IsEmpty) { return; } Performance.Start(out string reference); double width = Context.FromPixels(r - l); double height = Context.FromPixels(b - t); Performance.Start(reference, "Element.Layout"); var orientation = Context.Resources.Configuration.Orientation; Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion(_contentViewRenderer.Element, new Rectangle(0, 0, width, height)); Performance.Stop(reference, "Element.Layout"); _contentViewRenderer.UpdateLayout(); Performance.Stop(reference); }
Rect LayoutPopup() { var popup = _popupBasePage.PopupViews [_currentPopup] as SlidePopupView; var metrics = _pageRenderer.Resources.DisplayMetrics; popup.CalucatePosition(); double x = popup.LeftMargin; double y = popup.TopMargin; double width = popup.WidthRequest <= 0 ? ScreenSizeHelper.ScreenWidth - popup.LeftMargin * 2 : popup.WidthRequest; double height = popup.HeightRequest <= 0 ? ScreenSizeHelper.ScreenHeight - popup.TopMargin * 2 : popup.HeightRequest; popup.Layout(new Xamarin.Forms.Rectangle(x, y, width, height)); _popupRenderer.UpdateLayout(); return(new Rect { left = x * metrics.Density, top = y * metrics.Density, right = (x + width) * metrics.Density, bottom = (y + height) * metrics.Density }); }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { var activity = (FormsAppCompatActivity)Context; int statusBarHeight = Forms.IsLollipopOrNewer ? activity.GetStatusBarHeight() : 0; if (changed) { if (_modal is MasterDetailPage) { _modal.Layout(new Rectangle(0, 0, activity.FromPixels(r - l), activity.FromPixels(b - t))); } else { _modal.Layout(new Rectangle(0, activity.FromPixels(statusBarHeight), activity.FromPixels(r - l), activity.FromPixels(b - t - statusBarHeight))); } _backgroundView.Layout(0, statusBarHeight, r - l, b - t); } _renderer.UpdateLayout(); }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { if (Element == null) { return; } ReadOnlyCollection <Element> children = ((IElementController)Element).LogicalChildren; foreach (Element element in children) { var visualElement = element as VisualElement; if (visualElement == null) { continue; } IVisualElementRenderer renderer = Platform.GetRenderer(visualElement); renderer?.UpdateLayout(); } }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { if (Element == null) { return; } ReadOnlyCollection <Element> children = Element.LogicalChildren; for (var i = 0; i < children.Count; i++) { var visualElement = children[i] as VisualElement; if (visualElement == null) { continue; } IVisualElementRenderer renderer = Platform.GetRenderer(visualElement); renderer?.UpdateLayout(); } }
Rect LayoutPopup() { var popup = _popupBasePage.PopupViews [_currentPopup] as SlidePopupView; var metrics = _pageRenderer.Resources.DisplayMetrics; TypedValue tv = new TypedValue(); int actionBarHeight = 0; if (Forms.Context.Theme.ResolveAttribute(Android.Resource.Attribute.ActionBarSize, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, Forms.Context.Resources.DisplayMetrics); } var targetRenderer = Platform.GetRenderer(popup.TargetControl); int[] array = new int[2]; targetRenderer.ViewGroup.GetLocationInWindow(array); popup.AdjustX = popup.AdjustX / metrics.Density; popup.AdjustY = popup.AdjustY / metrics.Density; popup.CalucatePosition(new Point { X = array[0] / metrics.Density, Y = (array[1] / metrics.Density) - (actionBarHeight / metrics.Density) }); double x = popup.LeftMargin; double y = popup.TopMargin; double width = popup.WidthRequest <= 0 ? ScreenSizeHelper.ScreenWidth - popup.LeftMargin * 2 : popup.WidthRequest; double height = popup.HeightRequest <= 0 ? ScreenSizeHelper.ScreenHeight - popup.TopMargin * 2 : popup.HeightRequest; System.Diagnostics.Debug.WriteLine($" {x} : {y} "); popup.Layout(new Xamarin.Forms.Rectangle(x, y, width, height)); _popupRenderer.UpdateLayout(); return(new Rect { left = x * metrics.Density, top = y * metrics.Density, right = (x + width) * metrics.Density, bottom = (y + height) * metrics.Density }); }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { if (_childView == null) { return; } Rectangle bounds = GetBounds(_isMaster, l, t, r, b); if (_isMaster) { MasterDetailPageController.MasterBounds = bounds; } else { MasterDetailPageController.DetailBounds = bounds; } IVisualElementRenderer renderer = Platform.GetRenderer(_childView); renderer?.UpdateLayout(); }
void AddMenu() { if (_basePage == null) { return; } var menu = _basePage.SlideMenu; if (menu == null) { return; } _basePage.HideMenuAction = () => { if (_dragGesture == null) { return; } var rect = _dragGesture.GetHidePosition(); _popMenuOverlayRenderer.View.Animate() .X((float)rect.left) .Y((float)rect.top) .SetDuration(menu.AnimationDurationMillisecond) .SetListener(new AnimatorListener(_dragGesture, false)) .Start(); }; _basePage.ShowMenuAction = () => { if (_dragGesture == null) { return; } var rect = _dragGesture.GetShowPosition(); _popMenuOverlayRenderer.View.Animate() .X((float)rect.left) .Y((float)rect.top) .SetDuration(menu.AnimationDurationMillisecond) .SetListener(new AnimatorListener(_dragGesture, true)) .Start(); }; if (_popMenuOverlayRenderer == null) { menu.Parent = (Page)_basePage; _popMenuOverlayRenderer = Platform.CreateRendererWithContext(menu, _context); Platform.SetRenderer(menu, _popupRenderer); var metrics = _pageRenderer.Resources.DisplayMetrics; var rootView = _popMenuOverlayRenderer.View; if (_popMenuOverlayRenderer is SlideMenuDroidRenderer) { _dragGesture = (_popMenuOverlayRenderer as SlideMenuDroidRenderer).GragGesture; } if (_dragGesture == null) { return; } var rect = _dragGesture.GetHidePosition(); menu.Layout(new Xamarin.Forms.Rectangle( rect.left / metrics.Density, rect.top / metrics.Density, (rect.right - rect.left) / metrics.Density, (rect.bottom - rect.top) / metrics.Density)); _popMenuOverlayRenderer.UpdateLayout(); _popMenuOverlayRenderer.View.Visibility = ViewStates.Visible; rootView.Layout((int)rect.left, (int)rect.top, (int)rect.right, (int)rect.bottom); _pageRenderer.ViewGroup.AddView(rootView); _pageRenderer.ViewGroup.BringChildToFront(rootView); _dragGesture.NeedShowBackgroundView = (open, alpha) => { if (open) { ShowBackgroundOverlay(alpha); } else { HideBackgroundOverlay(); } }; } }
void AddMenu() { if (_basePage == null) return; var menu = _basePage.SlideMenu; if (menu == null) return; _basePage.HideMenuAction = () => { if (_dragGesture == null) return; var rect = _dragGesture.GetHidePosition (); _popMenuOverlayRenderer.ViewGroup.Animate () .X ((float)rect.left) .Y ((float)rect.top) .SetDuration (menu.AnimationDurationMillisecond) .SetListener (new AnimatorListener (_dragGesture, false)) .Start (); }; _basePage.ShowMenuAction = () => { if (_dragGesture == null) return; var rect = _dragGesture.GetShowPosition (); _popMenuOverlayRenderer.ViewGroup.Animate () .X ((float)rect.left) .Y ((float)rect.top) .SetDuration (menu.AnimationDurationMillisecond) .SetListener (new AnimatorListener (_dragGesture, true)) .Start (); }; if (_popMenuOverlayRenderer == null) { _popMenuOverlayRenderer = RendererFactory.GetRenderer (menu); var metrics = _pageRenderer.Resources.DisplayMetrics; var rootView = _popMenuOverlayRenderer.ViewGroup; if (_popMenuOverlayRenderer is SlideMenuDroidRenderer) { _dragGesture = (_popMenuOverlayRenderer as SlideMenuDroidRenderer).GragGesture; } if (_dragGesture == null) return; var rect = _dragGesture.GetHidePosition (); menu.Layout (new Xamarin.Forms.Rectangle ( rect.left / metrics.Density, rect.top / metrics.Density, (rect.right - rect.left) / metrics.Density, (rect.bottom - rect.top) / metrics.Density)); _popMenuOverlayRenderer.UpdateLayout (); _popMenuOverlayRenderer.ViewGroup.Visibility = ViewStates.Visible; rootView.Layout ((int)rect.left, (int)rect.top, (int)rect.right, (int)rect.bottom); _pageRenderer.ViewGroup.AddView (rootView); _pageRenderer.ViewGroup.BringChildToFront (rootView); _dragGesture.NeedShowBackgroundView = (open, alpha) => { if (open) ShowBackgroundOverlay (alpha); else HideBackgroundOverlay (); }; } }
protected virtual void AddChildView(VisualElement childView) { _pageContainer = null; Page page = childView as NavigationPage ?? (Page)(childView as TabbedPage); if (page == null) { // The thing we're adding is not a NavigationPage or TabbedPage, so we can just use the old AddChildView if (_currentFragment != null) { if (!_parent.IsAttachedToRoot()) { return; } // But first, if the previous occupant of this container was a fragment, we need to remove it properly FragmentTransaction transaction = FragmentManager.BeginTransactionEx(); transaction.RemoveEx(_currentFragment); transaction.SetTransitionEx((int)FragmentTransit.None); if (IsAttachedToWindow) { ExecuteTransaction(transaction); } else { _transaction = transaction; } _currentFragment = null; } IVisualElementRenderer renderer = APlatform.GetRenderer(childView); if (renderer == null) { APlatform.SetRenderer(childView, renderer = APlatform.CreateRenderer(childView, Context)); } if (renderer.View.Parent != this) { if (renderer.View.Parent != null) { renderer.View.RemoveFromParent(); } SetDefaultBackgroundColor(renderer); AddView(renderer.View); renderer.UpdateLayout(); } } else { if (!_parent.IsAttachedToRoot()) { return; } // The renderers for NavigationPage and TabbedPage both host fragments, so they need to be wrapped in a // FragmentContainer in order to get isolated fragment management Fragment fragment = FragmentContainer.CreateInstance(page); var fc = fragment as FragmentContainer; fc?.SetOnCreateCallback(pc => { _pageContainer = pc; UpdateFlowDirection(); SetDefaultBackgroundColor(pc.Child); }); FragmentTransaction transaction = FragmentManager.BeginTransactionEx(); if (_currentFragment != null) { transaction.RemoveEx(_currentFragment); } transaction.AddEx(Id, fragment); transaction.SetTransitionEx((int)FragmentTransit.None); if (IsAttachedToWindow) { ExecuteTransaction(transaction); } else { _transaction = transaction; } _currentFragment = fragment; } }