Example #1
0
        protected virtual void MeasureChild(RecyclerView parent, RecyclerViewItem child)
        {
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (child == null)
            {
                throw new ArgumentNullException(nameof(child));
            }

            if (child.Layout == null)
            {
                return;
            }

            //FIXME: This measure can be restricted size of child to be less than parent size.
            // but our parent can be not calculated yet, also some child can be bigger than it's parent size,
            // so we use implicit value 9999 as restricted specification.
            MeasureSpecification childWidthMeasureSpec = LayoutGroup.GetChildMeasureSpecification(
                new MeasureSpecification(new LayoutLength(9999), MeasureSpecification.ModeType.Exactly),
                new LayoutLength(0),
                new LayoutLength(child.WidthSpecification));

            MeasureSpecification childHeightMeasureSpec = LayoutGroup.GetChildMeasureSpecification(
                new MeasureSpecification(new LayoutLength(9999), MeasureSpecification.ModeType.Exactly),
                new LayoutLength(0),
                new LayoutLength(child.HeightSpecification));

            child.Layout.Measure(childWidthMeasureSpec, childHeightMeasureSpec);
        }
Example #2
0
        protected virtual void MeasureChild(RecyclerView parent, RecyclerViewItem child)
        {
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (child == null)
            {
                throw new ArgumentNullException(nameof(child));
            }

            if (child.Layout == null)
            {
                return;
            }

            //FIXME: This measure can be restricted size of child to be less than parent size.
            // but in some multiple-line TextLabel can be long enough to over the it's parent size.

            MeasureSpecification childWidthMeasureSpec = LayoutGroup.GetChildMeasureSpecification(
                new MeasureSpecification(new LayoutLength(parent.Size.Width - parent.Padding.Start - parent.Padding.End - child.Margin.Start - child.Margin.End), MeasureSpecification.ModeType.Exactly),
                new LayoutLength(0),
                new LayoutLength(child.WidthSpecification));

            MeasureSpecification childHeightMeasureSpec = LayoutGroup.GetChildMeasureSpecification(
                new MeasureSpecification(new LayoutLength(parent.Size.Height - parent.Padding.Top - parent.Padding.Bottom - child.Margin.Top - child.Margin.Bottom), MeasureSpecification.ModeType.Exactly),
                new LayoutLength(0),
                new LayoutLength(child.HeightSpecification));

            child.Layout.Measure(childWidthMeasureSpec, childHeightMeasureSpec);
        }
Example #3
0
        public void LayoutGroupGetChildMeasureSpecification()
        {
            tlog.Debug(tag, $"LayoutGroupGetChildMeasureSpecification START");

            MeasureSpecification parentMeasureSpec = new MeasureSpecification(new LayoutLength(10), MeasureSpecification.ModeType.Exactly);
            LayoutLength         padding           = new LayoutLength(0);
            LayoutLength         childDimension    = new LayoutLength(10);

            MeasureSpecification measureSpec = LayoutGroup.GetChildMeasureSpecification(parentMeasureSpec, padding, childDimension);

            Assert.AreEqual((double)(measureSpec.GetSize().AsRoundedValue()), 10.0f, "Should be the value set.");
            Assert.AreEqual(measureSpec.GetMode(), MeasureSpecification.ModeType.Exactly, "ModeType should match.");

            tlog.Debug(tag, $"LayoutGroupGetChildMeasureSpecification END (OK)");
        }