Cheesebaron.SlidingUpPanel.SlidingUpPanelLayout.OnLayout C# (CSharp) Method

OnLayout() protected method

protected OnLayout ( bool changed, int l, int t, int r, int b ) : void
changed bool
l int
t int
r int
b int
return void
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            if (_firstLayout)
            {
                switch (_slideState)
                {
                    case SlideState.Expanded:
                        _slideOffset = _canSlide ? 0.0f : 1.0f;
                        break;
                    case SlideState.Anchored:
                        _slideOffset = _canSlide ? _anchorPoint : 1.0f;
                        break;
                    case SlideState.Collapsed:
                        _slideOffset = 1.0f;
                        break;
                }
            }

            for (var i = 0; i < ChildCount; i++)
            {
                var child = GetChildAt(i);

                if (child.Visibility == ViewStates.Gone)
                    continue;

                var lp = (LayoutParams) child.LayoutParameters;
                var childHeight = child.MeasuredHeight;

                if (lp.Slideable)
                    _slideRange = childHeight - _panelHeight;

                int childTop;
                if (_isSlidingUp)
                    childTop = lp.Slideable ? SlidingTop + (int) (_slideRange * _slideOffset) : PaddingTop;
                else
                    childTop = lp.Slideable ? SlidingTop - (int)(_slideRange * _slideOffset) : PaddingTop + PanelHeight;

                var childBottom = childTop + childHeight;
                var childLeft = PaddingLeft;
                var childRight = childLeft + child.MeasuredWidth;

                child.Layout(childLeft, childTop, childRight, childBottom);
            }

            if (_firstLayout)
                UpdateObscuredViewVisibility();

            _firstLayout = false;
        }