Cheesebaron.ParallaxScrollView.ParallaxScrollView.OnMeasure C# (CSharp) Method

OnMeasure() protected method

protected OnMeasure ( int widthMeasureSpec, int heightMeasureSpec ) : void
widthMeasureSpec int
heightMeasureSpec int
return void
        protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
        {
            base.OnMeasure(widthMeasureSpec, heightMeasureSpec);

            if (_scrollView != null)
            {
                MeasureChild(_scrollView, MeasureSpec.MakeMeasureSpec(
                    MeasureSpec.GetSize(widthMeasureSpec), MeasureSpecMode.AtMost),
                    MeasureSpec.MakeMeasureSpec(MeasureSpec.GetSize(heightMeasureSpec),
                    MeasureSpecMode.AtMost));

                _scrollContentHeight = _scrollView.GetChildAt(0).MeasuredHeight;
                _scrollViewHeight = _scrollView.MeasuredHeight;
            }
            if (_background != null)
            {
                var minHeight = (int) (_scrollViewHeight + _parallaxOffset
                                   * (_scrollContentHeight - _scrollViewHeight));
                minHeight = Math.Max(minHeight, MeasureSpec.GetSize(heightMeasureSpec));

                MeasureChild(_background, MeasureSpec.MakeMeasureSpec(
                    MeasureSpec.GetSize(widthMeasureSpec), MeasureSpecMode.Exactly),
                    MeasureSpec.MakeMeasureSpec(minHeight, MeasureSpecMode.Exactly));

                _backgroundRight = Left + _background.MeasuredWidth;
                _backgroundBottom = Top + _background.MeasuredHeight;

                _scrollDiff = (_background.MeasuredHeight - _scrollViewHeight)
                              / (float) (_scrollContentHeight - _scrollViewHeight);
            }
        }