本文整理汇总了C#中RecyclerView.GetChildAt方法的典型用法代码示例。如果您正苦于以下问题:C# RecyclerView.GetChildAt方法的具体用法?C# RecyclerView.GetChildAt怎么用?C# RecyclerView.GetChildAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.GetChildAt方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDrawOver
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);
}
}
示例2: DrawVertical
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);
}
}
}
示例3: DrawVertical
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);
}
}
示例4: DrawHorizontal
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);
}
}
示例5: OnDrawOver
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);
}
}
示例6: DrawVertical
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);
}
}
示例7: OnDraw
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);
}
}
}
}
示例8: OnDraw
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);
}
}
示例9: OnDraw
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);
}
}
示例10: OnScrolled
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);
}
示例11: OnScrolled
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);
}
示例12: CanRecyclerViewScroll
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);
}
示例13: OnDrawOver
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);
}
}