protected override void OnLayout(bool changed, int left, int top, int right, int bottom) { using (var h = new Handler(Looper.MainLooper)) { h.Post(() => { double width = base.Context.FromPixels((double)(right - left)); double height = base.Context.FromPixels((double)(bottom - top)); var size = new Xamarin.Forms.Size(width, height); var msw = MeasureSpec.MakeMeasureSpec(right - left, MeasureSpecMode.Exactly); var msh = MeasureSpec.MakeMeasureSpec(bottom - top, MeasureSpecMode.Exactly); _nativeView.Measure(msw, msh); _nativeView.Layout(0, 0, right - left, bottom - top); if (size != _previousSize || !_isLaidOut) { if (_viewCell.View is Layout layout) { layout.Layout(new Rectangle(0, 0, width, height)); //Doesn't appear to be necessary? //layout.ForceLayout(); //FixChildLayouts(layout); _isLaidOut = true; } } _previousSize = size; }); } }
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) { base.OnMeasure(widthMeasureSpec, heightMeasureSpec); _view.Measure(widthMeasureSpec, heightMeasureSpec); SetMeasuredDimension(_view.MeasuredWidth, _view.MeasuredHeight); }
private void MeasureChildWithMarginsOverride( AndroidView child, int parentWidthMeasureSpec, int widthUsed, int childWidth, int parentHeightMeasureSpec, int heightUsed, int childHeight) { var layoutParams = (LayoutParams)child.LayoutParameters; int childWidthMeasureSpec = GetChildMeasureSpec( parentWidthMeasureSpec, this.PaddingLeft + this.PaddingRight + layoutParams.LeftMargin + layoutParams.RightMargin + widthUsed, childWidth); int childHeightMeasureSpec = GetChildMeasureSpec( parentHeightMeasureSpec, this.PaddingTop + this.PaddingBottom + layoutParams.TopMargin + layoutParams.BottomMargin + heightUsed, childHeight); #if DEBUG var widthMode = MeasureSpec.GetMode(childWidthMeasureSpec); var heightMode = MeasureSpec.GetMode(childHeightMeasureSpec); #endif child.Measure(childWidthMeasureSpec, childHeightMeasureSpec); }
void UpdateContentLayout() { VisualElement mauiControlsView = (View as VisualElement); AView aview = Content.NativeView; if (mauiControlsView == null || aview == null) { return; } var x = (int)Context.ToPixels(mauiControlsView.X); var y = (int)Context.ToPixels(mauiControlsView.Y); var width = Math.Max(0, (int)Context.ToPixels(mauiControlsView.Width)); var height = Math.Max(0, (int)Context.ToPixels(mauiControlsView.Height)); Content.NativeView.Layout(x, y, width, height); if ((aview is LayoutViewGroup || aview is ContentViewGroup || aview is CoordinatorLayout || aview is FragmentContainerView) && width == 0 && height == 0) { // Nothing to do here; just chill. } else { aview.Measure(MeasureSpecMode.Exactly.MakeMeasureSpec(width), MeasureSpecMode.Exactly.MakeMeasureSpec(height)); aview.Layout(x, y, x + width, y + height); } }
SizeRequest IVisualElementRenderer.GetDesiredSize(int widthConstraint, int heightConstraint) { AView view = this; view.Measure(widthConstraint, heightConstraint); return(new SizeRequest(new Size(MeasuredWidth, MeasuredHeight), MinimumSize())); }
public override void Draw(Canvas canvas) { base.Draw(canvas); var listAdapter = Control.Adapter; int totalHeight = Control.PaddingTop + Control.PaddingBottom; int desiredWidth = MeasureSpec.MakeMeasureSpec(Control.Width, MeasureSpecMode.AtMost); for (int i = 0; i < Control.Count; i++) { Android.Views.View listItem = listAdapter.GetView(i, null, Control); if (listItem != null) { // This next line is needed before you call measure or else you won't get measured height at all. The listitem needs to be drawn first to know the height. listItem.LayoutParameters = new Android.Widget.RelativeLayout.LayoutParams(-2, -2); listItem.Measure(desiredWidth, 0); totalHeight += listItem.MeasuredHeight; } } LayoutParams param = Control.LayoutParameters; Element.HeightRequest = totalHeight + (Control.DividerHeight * (Control.Count - 1)); }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { base.OnLayout(changed, l, t, r, b); //if (changed) { //var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly); if (actionBarCustomView != null) { var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly); AddCustomMenuView(); int x2 = r - l; if (msw <= 0) { msw = (int)Globals.ScreenWidth; } if (x2 <= 0) { x2 = (int)Globals.ScreenWidth; } actionBarCustomView.Measure(msw, BaseUIHelper.ConvertDPToPixels(50)); //MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly)); actionBarCustomView.Layout(0, 0, x2, BaseUIHelper.ConvertDPToPixels(50)); //b - t); actionBarCustomView.Visibility = ViewStates.Visible; } } }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { base.OnLayout(changed, l, t, r, b); var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly); var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly); _view.Measure(msw, msh); _view.Layout(0, 0, r - l, b - t); }
public override void PlatformArrange(Rectangle frame) { // This is a hack to force the shimmed control to actually do layout; without this, some controls won't actually // call OnLayout after SetFrame if their sizes haven't changed (e.g., ScrollView) // Luckily, measuring with MeasureSpecMode.Exactly is pretty fast, since it just returns the value you give it. PlatformView?.Measure(MeasureSpecMode.Exactly.MakeMeasureSpec((int)frame.Width), MeasureSpecMode.Exactly.MakeMeasureSpec((int)frame.Height)); base.PlatformArrange(frame); }
public Bitmap LayoutToBitmap(Android.Views.View markerLayout) { markerLayout.Measure(Android.Views.View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified), Android.Views.View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified)); markerLayout.Layout(0, 0, markerLayout.MeasuredWidth, markerLayout.MeasuredHeight); Bitmap bitmap = Bitmap.CreateBitmap(markerLayout.MeasuredWidth, markerLayout.MeasuredHeight, Bitmap.Config.Argb8888); Canvas canvas = new Canvas(bitmap); markerLayout.Draw(canvas); return(bitmap); }
/** * ´Óview µÃµ½Í¼Æ¬ * @param view * @return */ public static Bitmap GetBitmapFromView(View view) { view.DestroyDrawingCache(); view.Measure(View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified), View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified)); view.Layout(0, 0, view.MeasuredWidth, view.MeasuredHeight); view.DrawingCacheEnabled = true; Bitmap bitmap = view.GetDrawingCache(true); return bitmap; }
protected override void OnLayout(bool changed, int left, int top, int right, int bottom) { //base.OnLayout(changed, left, top, right, bottom); var msw = MeasureSpec.MakeMeasureSpec(right - 1, MeasureSpecMode.Exactly); var msh = MeasureSpec.MakeMeasureSpec(bottom - 1, MeasureSpecMode.Exactly); //_view.Measure(right, bottom); _view.Measure(msw, msh); _view.Layout(0, 0, right, bottom - top); }
/// <summary>Helps to force width value before calling requestLayout by the system.</summary> public static void SetWidth(Android.Views.View view, int width) { // Change width value from params ((RecyclerView.LayoutParams)view.LayoutParameters).Width = width; int widthMeasureSpec = View.MeasureSpec.MakeMeasureSpec(width, MeasureSpecMode.Exactly); int heightMeasureSpec = View.MeasureSpec.MakeMeasureSpec(view.MeasuredHeight, MeasureSpecMode.Exactly); view.Measure(widthMeasureSpec, heightMeasureSpec); view.RequestLayout(); }
/* * With Xamarin.Forms we never passed in an infinite height. The height was always constrained to something. * In MAUI if the Maui.ListView is inside a VerticalStackLayout then it basically has infinite height to occupy. * One of the quirks of the Androids platform ListView control is that if you give it infinite height * It will only measure the top cell. If you google "ListView only renders first cell" you'll find a bunch of hits * where people have put an Android.ListView inside an Android.ScrollView and the fix is to remove the Android.ScrollView * Our problem here is basically the same. So, in order to preserve behavior here from XF and make this work the same as * Windows/iOS we measure every single cell and then return that as the height. * This will most likely cause the user to be frustrated that the ListView doesn't scroll :-) but at least now * it's consistent between platforms and for cases where it doesn't need to scroll (TableView). * */ public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint) { if (double.IsInfinity(heightConstraint)) { if (Element.RowHeight > -1) { heightConstraint = (int)(_adapter.Count * Element.RowHeight); } else if (_adapter != null) { double totalHeight = 0; int adapterCount = _adapter.Count; for (int i = 0; i < adapterCount; i++) { var cell = _adapter.GetCellsFromPosition(i, 1)[0]; if (cell.Height > -1) { totalHeight += cell.Height; continue; } // If the parent is already set then we'll just pass // that in as the convert view so that GetView doesn't create // an additional ConditionalFocusLayout // We're basically faking re-use to the GetView call AView currentParent = null; if (cell.Handler?.PlatformView is AView aView) { currentParent = aView.Parent as AView; } currentParent ??= _adapter.GetConvertViewForMeasuringInfiniteHeight(i); AView listItem = _adapter.GetView(i, currentParent, Control); int widthSpec; if (double.IsInfinity(widthConstraint)) { widthSpec = MeasureSpecMode.Unspecified.MakeMeasureSpec(0); } else { widthSpec = MeasureSpecMode.AtMost.MakeMeasureSpec((int)Context.ToPixels(widthConstraint)); } listItem.Measure(widthSpec, MeasureSpecMode.Unspecified.MakeMeasureSpec(0)); totalHeight += Context.FromPixels(listItem.MeasuredHeight); } heightConstraint = totalHeight; } } return(base.GetDesiredSize(widthConstraint, heightConstraint)); }
protected void Layout(VisualElement element, AView nativeView) { var size = element.Measure(double.PositiveInfinity, double.PositiveInfinity, MeasureFlags.IncludeMargins); var width = size.Request.Width; var height = size.Request.Height; element.Layout(new Rect(0, 0, width, height)); int widthSpec = AView.MeasureSpec.MakeMeasureSpec((int)width, MeasureSpecMode.Exactly); int heightSpec = AView.MeasureSpec.MakeMeasureSpec((int)height, MeasureSpecMode.Exactly); nativeView.Measure(widthSpec, heightSpec); nativeView.Layout(0, 0, (int)width, (int)height); }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { base.OnLayout(changed, l, t, r, b); System.Diagnostics.Debug.WriteLine("CameraPageRenderer.OnLayout"); var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly); var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly); view.Measure(msw, msh); view.Layout(0, 0, r - l, b - t); }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { base.OnLayout(changed, l, t, r, b); var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly); var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly); _view.Measure(msw, msh); var y = (int)(_header != null ? _header.Bounds.Height * DeviceDisplay.MainDisplayInfo.Density : 0); _view.Layout(0, y, r - l, b - t); }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { base.OnLayout(changed, l, t, r, b); var w = r - l; var h = b - t; var msw = MeasureSpec.MakeMeasureSpec(w, MeasureSpecMode.Exactly); var msh = MeasureSpec.MakeMeasureSpec(h, MeasureSpecMode.Exactly); view.Measure(msw, msh); view.Layout(0, 0, w, h); }
public Drawable GetThumb(int progress) { ((TextView)thumbView.FindViewById(Resource.Id.thumbText)).SetText(String.Format(control.ThumbTextFormat, progress), BufferType.Normal); thumbView.Measure((int)MeasureSpecMode.Unspecified, (int)MeasureSpecMode.Unspecified); Bitmap bitmap = Bitmap.CreateBitmap(thumbView.MeasuredWidth, thumbView.MeasuredHeight, Bitmap.Config.Argb8888); Canvas canvas = new Canvas(bitmap); thumbView.Layout(0, 0, thumbView.MeasuredWidth, thumbView.MeasuredHeight); thumbView.Draw(canvas); return(new BitmapDrawable(Resources, bitmap)); }
private void SetupLargeTab() { var tabBar = (CustomTabbar)ShellItem; bottomView.Measure((int)MeasureSpecMode.Unspecified, (int)MeasureSpecMode.Unspecified); outerlayout.Measure((int)MeasureSpecMode.Unspecified, (int)MeasureSpecMode.Unspecified); shellOverlay.RemoveAllViews(); shellOverlay.AddView(ConvertFormsToNative(tabBar.TabBarView, new Xamarin.Forms.Rectangle(0, 0, Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Width / Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Density, (double)bottomView?.MeasuredHeight / Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Density))); // If I do not hide navigation bar, I have to use Resources.DisplayMetrics.WidthPixels (instead of DeviceDisplay.MainDisplayInfo.Width) because I want the width of the screen without the height of the navigation bar. }
public static Bitmap ConvertViewToBitmap(Android.Views.View v) { v.SetLayerType(LayerType.Hardware, null); v.DrawingCacheEnabled = true; v.Measure(Android.Views.View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified), Android.Views.View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified)); v.Layout(0, 0, v.MeasuredWidth, v.MeasuredHeight); v.BuildDrawingCache(true); Bitmap b = Bitmap.CreateBitmap(v.GetDrawingCache(true)); v.DrawingCacheEnabled = false; // clear drawing cache return(b); }
public void UpdateLayout() { Performance.Start(out string reference); VisualElement view = _renderer.Element; AView aview = _renderer.View; var headlessOffset = CompressedLayout.GetHeadlessOffset(view); var x = (int)_context.ToPixels(view.X + headlessOffset.X); var y = (int)_context.ToPixels(view.Y + headlessOffset.Y); var width = Math.Max(0, (int)_context.ToPixels(view.Width)); var height = Math.Max(0, (int)_context.ToPixels(view.Height)); if (aview is FormsViewGroup formsViewGroup) { Performance.Start(reference, "MeasureAndLayout"); formsViewGroup.MeasureAndLayout(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.Exactly), x, y, x + width, y + height); Performance.Stop(reference, "MeasureAndLayout"); } else if (aview is LayoutViewGroup && width == 0 && height == 0) { // Nothing to do here; just chill. } else { Performance.Start(reference, "Measure"); aview.Measure(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.Exactly)); Performance.Stop(reference, "Measure"); Performance.Start(reference, "Layout"); aview.Layout(x, y, x + width, y + height); Performance.Stop(reference, "Layout"); } // If we're running sufficiently new Android, we have to make sure to update the ClipBounds to // match the new size of the ViewGroup if ((int)Forms.SdkInt >= 18) { UpdateClipToBounds(); } UpdateClip(); Performance.Stop(reference); //On Width or Height changes, the anchors needs to be updated UpdateAnchorX(); UpdateAnchorY(); }
public static Bitmap LoadBitmapFromView(Android.Views.View v) { if (v.MeasuredHeight <= 0) { v.Measure(50, 50); Bitmap b = Bitmap.CreateBitmap(v.MeasuredWidth, v.MeasuredHeight, Bitmap.Config.Argb8888); Canvas c = new Canvas(b); v.Layout(0, 0, v.MeasuredWidth, v.MeasuredHeight); v.Draw(c); return(b); } return(null); }
protected void WireUpForceUpdateSizeRequested(Cell cell, AView nativeCell) { cell.ForceUpdateSizeRequested -= _onForceUpdateSizeRequested; _onForceUpdateSizeRequested = delegate { // RenderHeight may not be changed, but that's okay, since we // don't actually use the height argument in the OnMeasure override. nativeCell.Measure(nativeCell.Width, (int)cell.RenderHeight); nativeCell.SetMinimumHeight(nativeCell.MeasuredHeight); nativeCell.SetMinimumWidth(nativeCell.MeasuredWidth); }; cell.ForceUpdateSizeRequested += _onForceUpdateSizeRequested; }
public void UpdateLayout() { var reference = Guid.NewGuid().ToString(); Performance.Start(reference); VisualElement view = _renderer.Element; AView aview = _renderer.View; var headlessOffset = CompressedLayout.GetHeadlessOffset(view); var x = (int)_context.ToPixels(view.X + headlessOffset.X); var y = (int)_context.ToPixels(view.Y + headlessOffset.Y); var width = Math.Max(0, (int)_context.ToPixels(view.Width)); var height = Math.Max(0, (int)_context.ToPixels(view.Height)); var formsViewGroup = aview as FormsViewGroup; if (formsViewGroup == null) { Performance.Start(reference, "Measure"); aview.Measure(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.Exactly)); Performance.Stop(reference, "Measure"); Performance.Start(reference, "Layout"); aview.Layout(x, y, x + width, y + height); Performance.Stop(reference, "Layout"); } else { Performance.Start(reference, "MeasureAndLayout"); formsViewGroup.MeasureAndLayout(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.Exactly), x, y, x + width, y + height); Performance.Stop(reference, "MeasureAndLayout"); } // If we're running sufficiently new Android, we have to make sure to update the ClipBounds to // match the new size of the ViewGroup if ((int)Build.VERSION.SdkInt >= 18) { UpdateClipToBounds(); } Performance.Stop(reference); //On Width or Height changes, the anchors needs to be updated UpdateAnchorX(); UpdateAnchorY(); }
protected override Android.Views.View GetCellCore(Cell item, Android.Views.View convertView, ViewGroup parent, Context context) { Android.Views.View cell = base.GetCellCore(item, convertView, parent, context); cell.Measure(parent.Width, parent.Height); //var a = cell.Width; //var b = cell.Height; //var c = cell.MinimumWidth; //var d = cell.MinimumHeight; //var e = cell.MeasuredWidth; var f = cell.MeasuredHeight; //var g = cell.MeasuredWidthAndState; //var h = cell.MeasuredHeightAndState; CurrentCellHeight = cell.MeasuredHeight; return(cell); }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { base.OnLayout(changed, l, t, r, b); try { var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly); var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly); _View.Measure(msw, msh); _View.Layout(0, 0, r - l, b - t); } catch (Exception ex) { Console.WriteLine("DROID_SCAN | OnLayout error", ex); } }
private void FixLayoutSize(ViewGroup parent, View view) { if (view != null) { //specs for parent (recycler view) var widthSpec = View.MeasureSpec.MakeMeasureSpec(parent.Width, MeasureSpecMode.Exactly); var heightSpec = View.MeasureSpec.MakeMeasureSpec(parent.Height, MeasureSpecMode.Unspecified); //specs for children (headers) var childWidthSpec = ViewGroup.GetChildMeasureSpec(widthSpec, parent.PaddingLeft + parent.PaddingRight, view.LayoutParameters?.Width ?? 0); var childHeightSpec = ViewGroup.GetChildMeasureSpec(heightSpec, parent.PaddingTop + parent.PaddingBottom, view.LayoutParameters?.Height ?? 0); view.Measure(childWidthSpec, childHeightSpec); _stickyHeaderHeight = view.MeasuredHeight; view.Layout(0, 0, view.MeasuredWidth, _stickyHeaderHeight); } }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { base.OnLayout(changed, l, t, r, b); if (_androidLinearLayout != null) { var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly); var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly); _androidLinearLayout.Measure(msw, msh); _androidLinearLayout.Layout(0, 0, r - l, b - t); if (webView != null) { webView.Measure(msw, msh); webView.Layout(0, (int)toolbarHeight, r - l, b - t); } } }
public override Size GetDesiredSize(double widthConstraint, double heightConstraint) { if (double.IsInfinity(heightConstraint)) { if (Element.RowHeight > -1) { heightConstraint = (int)(_adapter.Count * Element.RowHeight); } else if (_adapter != null) { double totalHeight = 0; int adapterCount = _adapter.Count; for (int i = 0; i < adapterCount; i++) { var cell = (Cell)_adapter[i]; if (cell.Height > -1) { totalHeight += cell.Height; continue; } AView listItem = _adapter.GetView(i, null, Control); int widthSpec; if (double.IsInfinity(widthConstraint)) { widthSpec = MeasureSpecMode.Unspecified.MakeMeasureSpec(0); } else { widthSpec = MeasureSpecMode.AtMost.MakeMeasureSpec((int)Context.ToPixels(widthConstraint)); } listItem.Measure(widthSpec, MeasureSpecMode.Unspecified.MakeMeasureSpec(0)); totalHeight += Context.FromPixels(listItem.MeasuredHeight); } heightConstraint = totalHeight; } } return(base.GetDesiredSize(widthConstraint, heightConstraint)); }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { var width = r - l; var height = b - t; AView tabs = layout; tabs.Measure(MeasureSpec.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpec.MakeMeasureSpec(height, MeasureSpecMode.AtMost)); var tabsHeight = 0; if ((int)Build.VERSION.SdkInt >= 16) { tabsHeight = Math.Min(height, Math.Max(tabs.MeasuredHeight, tabs.MinimumHeight)); } else { tabsHeight = Math.Min(height, tabs.MeasuredHeight); } if (tabs.Visibility != ViewStates.Gone) { base.OnLayout(changed, l, t, r, b); base.OnLayout (changed, l, t + (int)tabsHeight - GetChildAt(1).MeasuredHeight, r, b ); viewpaper.Layout( l, t + (int)tabsHeight - GetChildAt(1).MeasuredHeight, r, b); tabs.Layout(0, 0, width, tabsHeight); } }
private void EnableExpandCollapse(View parent, View expandingView, int position) { if (parent == _expandedView && position != _expandedViewPosition) { // _expandedView has been recycled, _expandedView = null; } if (position == _expandedViewPosition) { // reset reference to _expandedView to maintain state and animation _expandedView = parent; } expandingView.Measure(parent.Width, parent.Height); LinearLayout.LayoutParams pms = (LinearLayout.LayoutParams)expandingView.LayoutParameters; if (position == _expandedViewPosition) { expandingView.Visibility = ViewStates.Visible; pms.BottomMargin = 0; } else { expandingView.Visibility = ViewStates.Gone; pms.BottomMargin = -expandingView.MeasuredHeight; } }
private void MeasureView(View child) { ViewGroup.LayoutParams p = child.LayoutParameters; if (p == null) p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent); int childWidthSpec = ViewGroup.GetChildMeasureSpec(0, 0 + 0, p.Width); int lpHeight = p.Height; int childHeightSpec; if (lpHeight > 0) { childHeightSpec = MeasureSpec.MakeMeasureSpec(lpHeight, MeasureSpecMode.Exactly); } else { childHeightSpec = MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified); } child.Measure(childWidthSpec, childHeightSpec); }
protected void WireUpForceUpdateSizeRequested(Cell cell, AView nativeCell) { cell.ForceUpdateSizeRequested -= _onForceUpdateSizeRequested; _onForceUpdateSizeRequested = delegate { // RenderHeight may not be changed, but that's okay, since we // don't actually use the height argument in the OnMeasure override. nativeCell.Measure(nativeCell.Width, (int)cell.RenderHeight); nativeCell.SetMinimumHeight(nativeCell.MeasuredHeight); nativeCell.SetMinimumWidth(nativeCell.MeasuredWidth); }; cell.ForceUpdateSizeRequested += _onForceUpdateSizeRequested; }