protected override void OnMeasure(MeasureSpec widthSpec, MeasureSpec heightSpec, Graphics g, Font font, Style style) { SizeF size = g.MeasureString(Value, font); SetDesiredSize(GetChildSize(widthSpec, size.Width), GetChildSize(heightSpec, size.Height)); }
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) { base.OnMeasure(widthMeasureSpec, heightMeasureSpec); MenuView.Measure(MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified), MeasureSpec.MakeMeasureSpec( MeasuredHeight, MeasureSpecMode.Exactly)); }
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int resWidth = 0; int resHeight = 0; int width = MeasureSpec.GetSize(widthMeasureSpec); int widthMode = (int)MeasureSpec.GetMode(widthMeasureSpec); int height = MeasureSpec.GetSize(heightMeasureSpec); int heightMode = (int)MeasureSpec.GetMode(heightMeasureSpec); if (widthMode != (int)MeasureSpecMode.Exactly || heightMode != (int)MeasureSpecMode.Exactly) { resWidth = this.SuggestedMinimumWidth; resWidth = resWidth == 0 ? getDefaultWidth() : resWidth; resHeight = this.SuggestedMinimumHeight; resHeight = resHeight == 0 ? getDefaultWidth() : resHeight; } else { resWidth = resHeight = Math.Min(width, height); } SetMeasuredDimension(resWidth, resHeight); mRadius = Math.Max(this.MeasuredWidth, this.MeasuredHeight); int count = ChildCount; // menu ite int childSize = (int)(mRadius * RADIO_DEFAULT_CHILD_DIMENSION); // menu item int childMode = (int)MeasureSpecMode.Exactly; for (int i = 0; i < count; i++) { View child = GetChildAt(i); if (child.Visibility == ViewStates.Gone) { continue; } // menu item int makeMeasureSpec = -1; if (child.Id == Resource.Id.circle_menu_item_center) { makeMeasureSpec = MeasureSpec.MakeMeasureSpec( (int)(mRadius * RADIO_DEFAULT_CENTERITEM_DIMENSION), MeasureSpec.GetMode(childMode)); } else { makeMeasureSpec = (int)MeasureSpec.MakeMeasureSpec(childSize, MeasureSpec.GetMode(childMode)); } child.Measure(makeMeasureSpec, makeMeasureSpec); } mPadding = RADIO_PADDING_LAYOUT * mRadius; }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { FormsViewPager pager = _viewPager; Context context = Context; var width = r - l; var height = b - t; if (IsBottomTabPlacement) { if (width <= 0 || height <= 0) { return; } _relativeLayout.Measure( MeasureSpec.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpec.MakeMeasureSpec(height, MeasureSpecMode.Exactly)); pager.Measure(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.AtMost), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.AtMost)); if (width > 0 && height > 0) { PageController.ContainerArea = new Graphics.Rect(0, 0, context.FromPixels(width), context.FromPixels(height - _bottomNavigationView.MeasuredHeight)); SetNavigationRendererPadding(0, _bottomNavigationView.MeasuredHeight); pager.Layout(0, 0, width, b); // We need to measure again to ensure that the tabs show up _relativeLayout.Measure( MeasureSpec.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpec.MakeMeasureSpec(height, MeasureSpecMode.Exactly)); _relativeLayout.Layout(0, 0, _relativeLayout.MeasuredWidth, _relativeLayout.MeasuredHeight); } } else { TabLayout tabs = _tabLayout; tabs.Measure(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.AtMost)); var tabsHeight = 0; if (tabs.Visibility != ViewStates.Gone) { tabsHeight = Math.Min(height, Math.Max(tabs.MeasuredHeight, tabs.MinimumHeight)); } pager.Measure(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.AtMost), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.AtMost)); if (width > 0 && height > 0) { PageController.ContainerArea = new Graphics.Rect(0, context.FromPixels(tabsHeight), context.FromPixels(width), context.FromPixels(height - tabsHeight)); SetNavigationRendererPadding(tabsHeight, 0); pager.Layout(0, 0, width, b); // We need to measure again to ensure that the tabs show up tabs.Measure(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(tabsHeight, MeasureSpecMode.Exactly)); tabs.Layout(0, 0, width, tabsHeight); UpdateTabBarTranslation(pager.CurrentItem, 0); } } base.OnLayout(changed, l, t, r, b); }