当前位置: 首页>>代码示例>>C#>>正文


C# RecyclerView.GetChildAt方法代码示例

本文整理汇总了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);
			}
		}
开发者ID:Dealtis,项目名称:oldDMS_3,代码行数:52,代码来源:DividerItemDecoration.cs

示例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);
                }
            }
        }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:15,代码来源:DividerItemDecoration.cs

示例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);
            }
        }
开发者ID:nepula-h-okuyama,项目名称:DroidKaigi2016Xamarin,代码行数:16,代码来源:DividerItemDecoration.cs

示例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);
              }
        }
开发者ID:kosomgua,项目名称:MapCross,代码行数:16,代码来源:DividerItemDecoration.cs

示例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);
            }
        }
开发者ID:garuma,项目名称:Cytotem,代码行数:17,代码来源:GraphEntryDecoration.cs

示例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);
            }
        }
开发者ID:fabionuno,项目名称:Timehop.StickyHeadersRecyclerView,代码行数:18,代码来源:DividerDecoration.cs

示例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);
                    }
                }
            }
        }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:41,代码来源:ShadowItemDecoration.cs

示例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);
            }
        }
开发者ID:T-Rex,项目名称:demo-android-article-list,代码行数:21,代码来源:SimpleItemDecoration.cs

示例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);
            }
        }
开发者ID:shaxxx,项目名称:SignalMeter,代码行数:21,代码来源:DividerItemDecoration.cs

示例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);
            }
开发者ID:dbeattie71,项目名称:FastScroll,代码行数:19,代码来源:FastScroller.cs

示例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);
			}
开发者ID:cyecp,项目名称:XamarinComponents,代码行数:19,代码来源:StickyHeaderRecyclerView.cs

示例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);
        }
开发者ID:devxiaruwei,项目名称:MaterialDialogs,代码行数:25,代码来源:MDRootLayout.cs

示例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);
			}
		}
开发者ID:Appercode,项目名称:monodroid-samples,代码行数:13,代码来源:AlarmAdapter.cs


注:本文中的RecyclerView.GetChildAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。