public override void OnDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { var left = parent.Left; var right = parent.Right; var childCount = parent.ChildCount; ViewHolder prevHolder = null; for (var i = 0; i < childCount; i++) { var child = parent.GetChildAt(i); var holder = parent.GetChildViewHolder(child) as ViewHolder; if (prevHolder != null && prevHolder is IHeaderViewHolder && !_settingsView.ShowSectionTopBottomBorder || holder is IFooterViewHolder && !_settingsView.ShowSectionTopBottomBorder || holder is IFooterViewHolder && !holder.RowInfo.Section.Any() || holder is IHeaderViewHolder || !holder.RowInfo.Section.IsVisible) { prevHolder = holder; continue; } var bottom = child.Top; var top = bottom - _drawable.IntrinsicHeight; _drawable.SetBounds(left, top, right, bottom); _drawable.Draw(c); prevHolder = holder; } }
public void More(int position) { morePosition = position; PopupMenu menu = new PopupMenu(this, ListView.GetChildAt(position - ((LinearLayoutManager)ListView.GetLayoutManager()).FindFirstVisibleItemPosition()).FindViewById <Android.Widget.ImageButton>(Resource.Id.more)); menu.Inflate(Resource.Menu.download_more); menu.SetOnMenuItemClickListener(this); menu.Show(); }
private void SaveButton(object s, object e) { bool success = true; for (int i = 2; i < template.Count; i++) { var view = recycler.GetChildAt(i); template[i] = view.FindViewById <EditText>(Resource.Id.EditTextView).Text; } for (int i = 2; i < template.Count; i++) { var view = recycler.GetChildAt(i); var editText = view.FindViewById <EditText>(Resource.Id.EditTextView); if (editText.Text == "" || editText.Text == null) { success = false; editText.Error = GetString(Resource.String.EmptyValue); } else if (template.Where(x => x == editText.Text).Count() > 1) { success = false; editText.Error = GetString(Resource.String.NameExists); } else { editText.Error = null; newTemplate.Add(editText.Text); } } if (success) { completionSource?.TrySetResult(newTemplate); Dismiss(); } else { newTemplate.Clear(); } }
public override void OnDrawOver (Canvas c, RecyclerView parent, RecyclerView.State state) { if (mDivider == null) { base.OnDrawOver (c, parent, state); return; } // Initialization needed to avoid compiler warning int left = 0, right = 0, top = 0, bottom = 0, size; int orientation = GetOrientation (parent); int childCount = parent.ChildCount; if (orientation == LinearLayoutManager.Vertical) { size = mDivider.IntrinsicHeight; left = parent.PaddingLeft; right = parent.Width - parent.PaddingRight; } else { //horizontal size = mDivider.IntrinsicWidth; top = parent.PaddingTop; bottom = parent.Height - parent.PaddingBottom; } for (int i = mShowFirstDivider ? 0 : 1; i < childCount; i++) { var child = parent.GetChildAt (i); var param = (RecyclerView.LayoutParams)child.LayoutParameters; if (orientation == LinearLayoutManager.Vertical) { top = child.Top - param.TopMargin; bottom = top + size; } else { //horizontal left = child.Left - param.LeftMargin; right = left + size; } mDivider.SetBounds (left, top, right, bottom); mDivider.Draw (c); } // show last divider if (mShowLastDivider && childCount > 0) { var child = parent.GetChildAt (childCount - 1); var param = (RecyclerView.LayoutParams)child.LayoutParameters; if (orientation == LinearLayoutManager.Vertical) { top = child.Bottom + param.BottomMargin; bottom = top + size; } else { // horizontal left = child.Right + param.RightMargin; right = left + size; } mDivider.SetBounds (left, top, right, bottom); mDivider.Draw (c); } }
public override void OnDraw(Canvas cValue, RecyclerView parent, RecyclerView.State state) { base.OnDraw(cValue, parent, state); _layout.Layout(parent.Left, 0, parent.Right, _layout.MeasuredHeight); for (int i = 0; i < parent.ChildCount; i++) { var view = parent.GetChildAt(i); if (parent.GetChildAdapterPosition(view) == parent.ChildCount - 1) { } } }
public override void OnDrawOver(Android.Graphics.Canvas cValue, RecyclerView parent, RecyclerView.State state) { int left = parent.PaddingLeft; int right = parent.Width - parent.PaddingRight; for (int i = 0; i < parent.ChildCount; i++) { View child = parent.GetChildAt(i); var param = (RecyclerView.LayoutParams)child.LayoutParameters; int top = child.Bottom + param.BottomMargin; int bottom = top + divider.IntrinsicHeight; divider.SetBounds(left, top, right, bottom); divider.Draw(cValue); } }
public void DrawVertical (Canvas c, RecyclerView parent) { var left = parent.PaddingLeft; var right = parent.PaddingRight; var childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { using (View child = parent.GetChildAt (i)) { var top = child.Bottom; var bottom = top + divider.IntrinsicHeight; divider.SetBounds (left, top, right, bottom); divider.Draw (c); } } }
public void DrawVertical(Canvas c, RecyclerView parent) { var left = parent.PaddingLeft; var right = parent.Width - parent.PaddingRight; var childCount = parent.ChildCount; for (var i = 0; i < childCount; i++) { var child = parent.GetChildAt(i); var lparams = child.LayoutParameters as RecyclerView.LayoutParams; var top = child.Bottom + lparams.BottomMargin; var bottom = top + divider.IntrinsicHeight; divider.SetBounds(left, top, right, bottom); divider.Draw(c); } }
public void DrawHorizontal(Canvas c, RecyclerView parent) { var top = parent.PaddingTop; var bottom = parent.PaddingBottom; var childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { var child = parent.GetChildAt(i); var layoutParams = child.LayoutParameters.JavaCast<RecyclerView.MarginLayoutParams>(); var left = child.Right + layoutParams.RightMargin; var right = left + divider.IntrinsicHeight; divider.SetBounds(left, top, right, bottom); divider.Draw(c); } }
private float ComputeRatio(RecyclerView recyclerView) { View child0 = recyclerView.GetChildAt(0); int pos = recyclerView.GetChildAdapterPosition(child0); if (pos != 0) { return(0); } int height = child0.Height; float y = Math.Max(0, child0.GetY()); return(y / height); }
public void drawVertical(Canvas c, RecyclerView parent) { int left = parent.PaddingLeft; int right = parent.Width - parent.PaddingRight; int childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { View child = parent.GetChildAt(i); RecyclerView.LayoutParams parameters = (RecyclerView.LayoutParams)child.LayoutParameters; int top = child.Bottom + parameters.BottomMargin; int bottom = top + mDivider.IntrinsicHeight; mDivider.SetBounds(left, top, right, bottom); mDivider.Draw(c); } }
public void DrawHorizontal(Canvas c, RecyclerView parent) { var top = parent.PaddingTop; var bottom = parent.PaddingBottom; var childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { var child = parent.GetChildAt(i); var layoutParams = child.LayoutParameters.JavaCast <RecyclerView.MarginLayoutParams>(); var left = child.Right + layoutParams.RightMargin; var right = left + divider.IntrinsicHeight; divider.SetBounds(left, top, right, bottom); divider.Draw(c); } }
public void DrawVertical(Canvas c, RecyclerView parent) { var left = parent.PaddingLeft; var right = parent.PaddingRight; var childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { var child = parent.GetChildAt(i); var layoutParams = child.LayoutParameters.JavaCast <RecyclerView.MarginLayoutParams>(); var top = child.Bottom + layoutParams.BottomMargin; var bottom = top + divider.IntrinsicHeight; divider.SetBounds(left, top, right, bottom); divider.Draw(c); } }
/** * Get position of center child in Y Axes */ public static int GetCenterYChildPosition(RecyclerView recyclerView) { int childCount = recyclerView.ChildCount; if (childCount > 0) { for (int i = 0; i < childCount; i++) { View child = recyclerView.GetChildAt(i); if (IsChildInCenterY(recyclerView, child)) { return(recyclerView.GetChildAdapterPosition(child)); } } } return(childCount); }
public override void OnDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { int left = parent.PaddingLeft; int right = parent.Width - parent.PaddingRight; int childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { View child = parent.GetChildAt(i); RecyclerView.LayoutParams parametres = (RecyclerView.LayoutParams)child.LayoutParameters; int top = child.Bottom + parametres.BottomMargin; int bottom = top + divider.IntrinsicHeight; divider.SetBounds(left, top, right, bottom); divider.Draw(c); } }
public void drawHorizontal(Canvas c, RecyclerView parent) { int top = parent.PaddingTop; int bottom = parent.Height - parent.PaddingBottom; int childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { View child = parent.GetChildAt(i); RecyclerView.LayoutParams parameters = (RecyclerView.LayoutParams)child.LayoutParameters; int left = child.Right + parameters.RightMargin; int right = left + mDivider.IntrinsicHeight; mDivider.SetBounds(left, top, right, bottom); mDivider.Draw(c); } }
public override void OnDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { var childCount = parent.ChildCount; if (childCount == 0) { return; } for (int i = 0; i + 1 < childCount; i++) { var child = parent.GetChildAt(i); var viewHolder = parent.GetChildViewHolder(child); Type type = viewHolder.GetType(); object[] attributes = type.GetCustomAttributes(typeof(ShadowAttribute), false); if (attributes.Length != 1) { continue; } ShadowAttribute shadowAttr = attributes [0] as ShadowAttribute; if (ShouldDraw(child) && shadowAttr != null) { var m = shadowAttr.Modes; var left = parent.PaddingLeft; var right = child.Right + child.PaddingRight; if (m.HasFlag(top) && topShadowHeightInPixels > 0 && parent.GetChildAdapterPosition(child) != 0) { var shadowBottom = child.Top + topShadowHeightInPixels; shadow.SetBounds(left, child.Top, right, shadowBottom); shadow.Draw(c); } if (m.HasFlag(bottom) && bottomShadowHeightInPixels > 0) { var reverseShadowTop = child.Bottom - bottomShadowHeightInPixels; reverseShadow.SetBounds(left, reverseShadowTop, right, child.Bottom); reverseShadow.Draw(c); } } } }
public override void OnDrawOver(Canvas cValue, RecyclerView parent, RecyclerView.State state) { var childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { var child = parent.GetChildAt (i); if (child.Visibility != Android.Views.ViewStates.Visible) continue; var left = child.Left; var right = child.Right; var top = child.Top + child.PaddingTop + child.TranslationY; var bottom = child.Bottom; cValue.DrawLine (left + .5f, top, left + .5f, bottom, lightPaint); cValue.DrawLine (right - .5f, top, right - .5f, bottom, darkPaint); } }
public override void OnDrawOver(Canvas cValue, RecyclerView parent, RecyclerView.State state) { int left = parent.PaddingLeft; int right = parent.Width - parent.PaddingRight; int childCount = parent.ChildCount; for (int i = 1; i < childCount; i++) { View child = parent.GetChildAt(i); RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams)child.LayoutParameters; int size = _dividerHeight; int top = child.Top - lp.TopMargin - _dividerHeight; int bottom = top + size; _divider.Bounds = new Rect(left, top, right, bottom); _divider.Draw(cValue); } }
/** * Get center child in Y Axes */ public static View GetCenterYChild(RecyclerView recyclerView) { int childCount = recyclerView.ChildCount; if (childCount > 0) { for (int i = 0; i < childCount; i++) { View child = recyclerView.GetChildAt(i); if (IsChildInCenterY(recyclerView, child)) { return(child); } } } return(null); }
public void DrawVertical(Canvas c, RecyclerView parent) { var left = parent.PaddingLeft; var right = parent.PaddingRight; var childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { using (View child = parent.GetChildAt(i)) { var top = child.Bottom; var bottom = top + divider.IntrinsicHeight; divider.SetBounds(left, top, right, bottom); divider.Draw(c); } } }
public void drawHorizontal(Canvas c, RecyclerView parent) { int childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { View child = parent.GetChildAt(i); RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams)child .LayoutParameters; int left = child.Left - layoutParams.LeftMargin; int right = child.Right + layoutParams.RightMargin + mDivider.IntrinsicWidth; int top = child.Bottom + layoutParams.BottomMargin; int bottom = top + mDivider.IntrinsicHeight; mDivider.SetBounds(left, top, right, bottom); mDivider.Draw(c); } }
private void DrawVertical(Canvas c, RecyclerView parent) { int left = parent.PaddingLeft; int right = parent.Width - parent.PaddingRight; int recyclerViewTop = parent.PaddingTop; int recyclerViewBottom = parent.Height - parent.PaddingBottom; int childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { View child = parent.GetChildAt(i); RecyclerView.LayoutParams layoutParams = child.LayoutParameters.JavaCast <RecyclerView.LayoutParams>(); int top = Math.Max(recyclerViewTop, child.Bottom + layoutParams.BottomMargin); int bottom = Math.Min(recyclerViewBottom, top + this.divider.IntrinsicHeight); this.divider.SetBounds(left, top, right, bottom); this.divider.Draw(c); } }
private void DrawVertical(Canvas c, RecyclerView parent) { int left = parent.PaddingLeft; int right = parent.Width - parent.PaddingRight; int recyclerViewTop = parent.PaddingTop; int recyclerViewBottom = parent.Height - parent.PaddingBottom; int childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { View child = parent.GetChildAt(i); RecyclerView.LayoutParams layoutParams = child.LayoutParameters.JavaCast<RecyclerView.LayoutParams>(); int top = Math.Max(recyclerViewTop, child.Bottom + layoutParams.BottomMargin); int bottom = Math.Min(recyclerViewBottom, top + this.divider.IntrinsicHeight); this.divider.SetBounds(left, top, right, bottom); this.divider.Draw(c); } }
public override void OnScrolled(RecyclerView recyclerView, int dx, int dy) { base.OnScrolled(recyclerView, dx, dy); if (scrolledY == int.MinValue) { var child = recyclerView.GetChildAt(0); var positionFirstItem = recyclerView.GetChildAdapterPosition(child); var heightDecorator = positionFirstItem == 0 ? 0 : headerView.heightHeader; var offset = recyclerView.ComputeVerticalScrollOffset(); scrolledY = offset + heightDecorator; } else { scrolledY += dy; } headerView.headerAnimator.OnScroll(-scrolledY); }
public override void OnDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { base.OnDraw(c, parent, state); int left = parent.PaddingLeft; int right = parent.Width - parent.PaddingRight; for (int i = 0; i < parent.ChildCount; i++) { View child = parent.GetChildAt(i); ViewGroup.MarginLayoutParams parameters = (ViewGroup.MarginLayoutParams)child.LayoutParameters; int top = child.Bottom + parameters.BottomMargin; int bottom = top + drawable.IntrinsicHeight; drawable.SetBounds(left, top, right, bottom); drawable.Draw(c); } }
public override void OnDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { int left = parent.Left; int right = parent.Right; int childCount = parent.ChildCount; CustomViewHolder?prevHolder = null; for (var i = 0; i < childCount; i++) { View?child = parent.GetChildAt(i); if (child is null) { continue; } if (!(parent.GetChildViewHolder(child) is CustomViewHolder holder)) { continue; } if (holder.RowInfo is null) { continue; } if ((prevHolder is IHeaderViewHolder && !_SettingsView.ShowSectionTopBottomBorder) || (holder is IFooterViewHolder && !_SettingsView.ShowSectionTopBottomBorder) || (holder is IFooterViewHolder && !holder.RowInfo.Section.Any()) || (holder is IHeaderViewHolder || !holder.RowInfo.Section.IsVisible)) { prevHolder = holder; continue; } int bottom = child.Top; int top = bottom - _Drawable.IntrinsicHeight; _Drawable.SetBounds(left, top, right, bottom); _Drawable.Draw(c); prevHolder = holder; } }
public override void OnDraw (Canvas c, RecyclerView parent, RecyclerView.State state) { var childCount = parent.ChildCount; if (childCount == 0) { return; } for (int i = 0; i+1 < childCount; i++) { var child = parent.GetChildAt (i); var viewHolder = parent.GetChildViewHolder (child); Type type = viewHolder.GetType (); object[] attributes = type.GetCustomAttributes (typeof (ShadowAttribute), false); if (attributes.Length != 1) { continue; } ShadowAttribute shadowAttr = attributes [0] as ShadowAttribute; if (ShouldDraw (child) && shadowAttr != null) { var m = shadowAttr.Modes; var left = parent.PaddingLeft; var right = child.Right + child.PaddingRight; if (m.HasFlag (top) && topShadowHeightInPixels > 0 && parent.GetChildAdapterPosition (child) != 0) { var shadowBottom = child.Top + topShadowHeightInPixels; shadow.SetBounds (left, child.Top, right, shadowBottom); shadow.Draw (c); } if (m.HasFlag (bottom) && bottomShadowHeightInPixels > 0) { var reverseShadowTop = child.Bottom - bottomShadowHeightInPixels; reverseShadow.SetBounds (left, reverseShadowTop, right, child.Bottom); reverseShadow.Draw (c); } } } }
public override void OnDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { base.OnDraw(c, parent, state); int left = parent.PaddingLeft; int right = parent.Width - parent.PaddingRight; for (int i = 0; i < parent.ChildCount; i++) { View child = parent.GetChildAt(i); ViewGroup.MarginLayoutParams parameters = (ViewGroup.MarginLayoutParams)child.LayoutParameters.JavaCast<RecyclerView.LayoutParams>(); //RecyclerView.LayoutParams parameters = (RecyclerView.LayoutParams)child.LayoutParameters; // InvalidCastException int top = child.Bottom + parameters.BottomMargin; int bottom = top + divider.IntrinsicHeight; divider.SetBounds(left, top, right, bottom); divider.Draw(c); } }
public override void OnDrawOver(Canvas cValue, RecyclerView parent, RecyclerView.State state) { var left = parent.PaddingLeft; var right = parent.Width - parent.PaddingRight; var childCount = parent.ChildCount; for (var i = 0; i < childCount; i++) { var child = parent.GetChildAt(i); var layoutParams = (RecyclerView.LayoutParams)child.LayoutParameters; var top = child.Bottom + layoutParams.BottomMargin + (int)child.TranslationY; var bottom = top + 2; _divider.Alpha = (int)(child.Alpha * 255); _divider.SetBounds(left, top, right, bottom); _divider.Draw(cValue); } }
public override void OnDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { int left = parent.PaddingLeft; int right = parent.Width - parent.PaddingRight; int childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { var child = parent.GetChildAt(i); // if (child.LayoutParameters is RecyclerView.LayoutParams) // { // RecyclerView.LayoutParams a = (RecyclerView.LayoutParams)child.LayoutParameters; // } // var mparams = ( RecyclerView.LayoutParams)child.LayoutParameters; int top = child.Bottom + 0; int bottom = top + mDivider.IntrinsicHeight; mDivider.SetBounds(left, top, right, bottom); mDivider.Draw(c); } }
//竖屏时画竖线 public void DrawVertical(Canvas c, RecyclerView parent) { int left = parent.PaddingLeft; int right = parent.Width - parent.PaddingRight; int childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { if (i + 1 == childCount) //最后一项不用画线 { return; } View childView = parent.GetChildAt(i); RecyclerView v = new RecyclerView(parent.Context); RecyclerView.LayoutParams _params = (RecyclerView.LayoutParams)childView.LayoutParameters; int top = childView.Bottom + _params.BottomMargin; int bottom = top + _divider.IntrinsicHeight; _divider.SetBounds(left, top, right, bottom); _divider.Draw(c); } }
public override void OnDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { base.OnDraw(c, parent, state); int dividerLeft = 32; int dividerRight = parent.Width - 32; for (int i = 0; i < parent.ChildCount; i++) { if (i != parent.ChildCount - 1) { View child = parent.GetChildAt(i); RecyclerView.LayoutParams @params = (RecyclerView.LayoutParams)child.LayoutParameters; int dividerTop = child.Bottom + @params.BottomMargin; int dividerBottom = dividerTop + mDivider.IntrinsicHeight; mDivider.SetBounds(dividerLeft, dividerTop, dividerRight, dividerBottom); mDivider.Draw(c); } } }
//横屏时画横线 public void DrawHorizontal(Canvas c, RecyclerView parent) { int top = parent.PaddingTop; int bottom = parent.Height - parent.PaddingBottom; int childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { if (i == childCount) //最后一项不用画线 { return; } View childView = parent.GetChildAt(i); RecyclerView v = new RecyclerView(parent.Context); RecyclerView.LayoutParams _params = (RecyclerView.LayoutParams)childView.LayoutParameters; int left = childView.Right + _params.RightMargin; int right = left + _divider.IntrinsicHeight; _divider.SetBounds(left, top, right, bottom); _divider.Draw(c); } }
private View GetChildInContact(RecyclerView parent, int contactPoint, int currentHeaderPosition) { View childInContact = null; for (int i = 0; i < parent.ChildCount; i++) { var heightTolerance = 0; var child = parent.GetChildAt(i); if (currentHeaderPosition != i) { var isChildHeader = IStickyHeaderRecyclerView.IsHeader(parent.GetChildAdapterPosition(child)); if (isChildHeader) { heightTolerance = _stickyHeaderHeight - child.Height; } } int childBottomPosition; if (child.Top > 0) { childBottomPosition = child.Bottom + heightTolerance; } else { childBottomPosition = child.Bottom; } if (childBottomPosition > contactPoint) { if (child.Top <= contactPoint) { childInContact = child; break; } } } return(childInContact); }
public override void OnDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { int left = parent.PaddingLeft; int right = parent.Width - parent.PaddingRight; int childCount = parent.GetAdapter().ItemCount; for (int i = 0; i < childCount; i++) { var child = parent.GetChildAt(i); if (child == null) { return; } var lp = (RecyclerView.LayoutParams)child.LayoutParameters; int top = (int)(child.Top + lp.TopMargin + lp.BottomMargin + child.TranslationY); c.DrawLine(left + ((i + 1 < childCount) ? _sideSpace : 0), top, right, top, _paint); } }
public override void OnDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { base.OnDrawOver(canvas, parent, state); var topChild = parent.GetChildAt(0); if (topChild == null) { return; } int topChildPosition = parent.GetChildAdapterPosition(topChild); if (topChildPosition == RecyclerView.NoPosition) { return; } View currentHeader = GetHeaderViewForItem(topChildPosition, parent); if (currentHeader == null) { return; } FixLayoutSize(parent, currentHeader); int contactPoint = currentHeader.Bottom; View childInContact = GetChildInContact(parent, contactPoint, topChildPosition); if (childInContact != null && IStickyHeaderRecyclerView.IsHeader(parent.GetChildAdapterPosition(childInContact))) { MoveHeader(canvas, currentHeader, childInContact); return; } DrawHeader(canvas, currentHeader); }
public override void OnDrawOver(Canvas cValue, RecyclerView parent, RecyclerView.State state) { var left = parent.PaddingLeft; var right = parent.Width - parent.PaddingRight; for (var i = 0; i < parent.ChildCount; i++) { var child = parent.GetChildAt(i); var parameters = child.LayoutParameters.JavaCast <RecyclerView.LayoutParams>(); var top = child.Bottom + parameters.BottomMargin; var bottom = top + _divider.IntrinsicHeight; _divider.SetBounds(left, top, right, bottom); if ((parent.GetChildAdapterPosition(child) == parent.GetAdapter().ItemCount - 1) && parent.Bottom < bottom) { // this prevent a parent to hide the last item's divider parent.SetPadding(parent.PaddingLeft, parent.PaddingTop, parent.PaddingRight, bottom - parent.Bottom); } _divider.Draw(cValue); } }
public override void OnDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { var offset = (int)(_bottomOffset / 2); // iterate over every visible view for (int i = 0; i < parent.ChildCount; i++) { var view = parent.GetChildAt(i); var parameters = (RecyclerView.LayoutParams)view.LayoutParameters; var position = parameters.ViewAdapterPosition; // finally draw the separator if (position < state.ItemCount) { c.DrawLine( view.Left + _leftOffset, view.Bottom + offset, view.Right, view.Bottom + offset, _paint); } } }
public override void OnScrolled(RecyclerView recyclerView, int dx, int dy) { View firstVisibleView = recyclerView.GetChildAt(0); int firstVisiblePosition = recyclerView.GetChildPosition(firstVisibleView); int visibleRange = recyclerView.ChildCount; int lastVisiblePosition = firstVisiblePosition + visibleRange; int itemCount = recyclerView.GetAdapter().ItemCount; int position; if(firstVisiblePosition==0) position=0; else if(lastVisiblePosition==itemCount-1) position = itemCount-1; else position = firstVisiblePosition; float proportion=(float)position/(float)itemCount; this.scroll.setPosition(scroll.height*proportion); }
public override void OnDrawOver (Android.Graphics.Canvas cValue, RecyclerView parent, RecyclerView.State state) { int left = parent.PaddingLeft; int right = parent.Width - parent.PaddingRight; for (int i = 0; i < parent.ChildCount; i++) { View child = parent.GetChildAt (i); var param = (RecyclerView.LayoutParams)child.LayoutParameters; int top = child.Bottom + param.BottomMargin; int bottom = top + divider.IntrinsicHeight; divider.SetBounds (left, top, right, bottom); divider.Draw (cValue); } }
public static bool CanRecyclerViewScroll(RecyclerView view) { if (view == null || view.GetAdapter() == null || view.GetLayoutManager() == null) return false; RecyclerView.LayoutManager lm = view.GetLayoutManager(); int count = view.GetAdapter().ItemCount; int lastVisible; if (lm is LinearLayoutManager) { LinearLayoutManager llm = (LinearLayoutManager)lm; lastVisible = llm.FindLastVisibleItemPosition(); } else { throw new InvalidOperationException("Material Dialogs currently only supports LinearLayoutManager. Please report any new layout managers."); } if (lastVisible == -1) return false; bool lastItemVisible = lastVisible == count - 1; return !lastItemVisible || (view.ChildCount > 0 && view.GetChildAt(view.ChildCount - 1).Bottom > view.Height - view.PaddingBottom); }