public SpaceItemDecoration(int spaceDp, Thickness paddingDp) { _space = PlatformHelper.DpToPixels(spaceDp); _leftPadding = PlatformHelper.DpToPixels(paddingDp.Left); _topPadding = PlatformHelper.DpToPixels(paddingDp.Top); _rightPadding = PlatformHelper.DpToPixels(paddingDp.Right); _bottomPadding = PlatformHelper.DpToPixels(paddingDp.Bottom); }
private void ScrollToCurrentItem() { if (Element.CurrentIndex == -1 || Control.GetAdapter() == null || Element.CurrentIndex >= Control.GetAdapter().ItemCount) { return; } int offset = 0; if (HorizontalLinearLayoutManager != null) { var itemWidth = PlatformHelper.DpToPixels(Element.ItemWidth + Element.ItemSpacing); var width = Control.MeasuredWidth; switch (Element.SnapStyle) { case SnapStyle.Center: offset = (width / 2) - (itemWidth / 2); break; } } LinearLayoutManager?.ScrollToPositionWithOffset(Element.CurrentIndex, offset); }
private void ComputeSpanCount(int recyclerWidth) { int spanCount = recyclerWidth / PlatformHelper.DpToPixels(_itemWidthDp + 2 * _marginDp); SpanCount = spanCount; }