public void UpdateUi(ViewCell viewCell, object dataContext, FastListView.Forms.VisualElements.FastListView listview, int height) { var contentLayout = (FrameLayout)ItemView; _listview = listview; _viewCell = viewCell; viewCell.BindingContext = dataContext; viewCell.Parent = listview; var metrics = Resources.System.DisplayMetrics; // Layout and Measure Xamarin Forms View var _view = Platform.CreateRendererWithContext(viewCell.View, Android.App.Application.Context); SizeRequest elementSizeRequest = _view.Element.Measure(Android.App.Application.Context.FromPixels(listview.Width), double.PositiveInfinity, MeasureFlags.IncludeMargins); var pixel_height = (int)Android.App.Application.Context.ToPixels(_viewCell.Height > 0 ? _viewCell.Height : elementSizeRequest.Request.Height); //var elementSizeRequest = viewCell.View.Measure(listview.Width, double.PositiveInfinity, MeasureFlags.IncludeMargins); var _height = (int)((elementSizeRequest.Request.Height + viewCell.View.Margin.Top + viewCell.View.Margin.Bottom) * metrics.Density); //var _height = (int)((height + viewCell.View.Margin.Top + viewCell.View.Margin.Bottom) * metrics.Density); var _width = (int)((listview.Width + viewCell.View.Margin.Left + viewCell.View.Margin.Right) * metrics.Density); viewCell.View.Layout(new Rectangle(0, 0, listview.Width, elementSizeRequest.Request.Height)); //viewCell.View.Layout(new Rectangle(0, 0, listview.Width, _height)); // Layout Android View var layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent) { Height = _height, Width = _width }; if (Platform.GetRenderer(viewCell.View) == null) { Platform.SetRenderer(viewCell.View, Platform.CreateRendererWithContext(viewCell.View, Android.App.Application.Context)); } var renderer = Platform.GetRenderer(viewCell.View); //var viewGroup = renderer.ViewGroup; var viewGroup = renderer.View; viewGroup.LayoutParameters = layoutParams; viewGroup.Layout(0, 0, _width, _height); contentLayout.RemoveAllViews(); contentLayout.AddView(viewGroup); }
public float CalculateHeightForCell(FastListView.Forms.VisualElements.FastListView fastListView, ViewCell cell) { var target = cell.View; if (_renderer == null) { _renderer = Platform.CreateRendererWithContext(target, Android.App.Application.Context); } else { _renderer.SetElement(target); } Platform.SetRenderer(target, _renderer); var req = target.Measure(fastListView.Width, double.PositiveInfinity, MeasureFlags.IncludeMargins); return((float)req.Request.Height); }
public RecyclerViewAdapter(FastListView.Forms.VisualElements.FastListView listView) { _fastListView = listView; _dataSource = (IList)listView.ItemsSource; }