Example #1
0
        protected internal override void onMeasure(int widthMeasureSpec, int heightMeasureSpec
                                                   )
        {
            int  count = getChildCount();
            bool measureMatchParentChildren = android.view.View.MeasureSpec.getMode(widthMeasureSpec
                                                                                    ) != android.view.View.MeasureSpec.EXACTLY || android.view.View.MeasureSpec.getMode
                                                  (heightMeasureSpec) != android.view.View.MeasureSpec.EXACTLY;

            mMatchParentChildren.clear();
            int maxHeight  = 0;
            int maxWidth   = 0;
            int childState = 0;

            {
                for (int i = 0; i < count; i++)
                {
                    android.view.View child = getChildAt(i);
                    if (mMeasureAllChildren || child.getVisibility() != GONE)
                    {
                        measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
                        android.widget.FrameLayout.LayoutParams lp = (android.widget.FrameLayout.LayoutParams
                                                                      )child.getLayoutParams();
                        maxWidth = System.Math.Max(maxWidth, child.getMeasuredWidth() + lp.leftMargin + lp
                                                   .rightMargin);
                        maxHeight = System.Math.Max(maxHeight, child.getMeasuredHeight() + lp.topMargin +
                                                    lp.bottomMargin);
                        childState = combineMeasuredStates(childState, child.getMeasuredState());
                        if (measureMatchParentChildren)
                        {
                            if (lp.width == android.view.ViewGroup.LayoutParams.MATCH_PARENT || lp.height ==
                                android.view.ViewGroup.LayoutParams.MATCH_PARENT)
                            {
                                mMatchParentChildren.add(child);
                            }
                        }
                    }
                }
            }
            // Account for padding too
            maxWidth  += getPaddingLeftWithForeground() + getPaddingRightWithForeground();
            maxHeight += getPaddingTopWithForeground() + getPaddingBottomWithForeground();
            // Check against our minimum height and width
            maxHeight = System.Math.Max(maxHeight, getSuggestedMinimumHeight());
            maxWidth  = System.Math.Max(maxWidth, getSuggestedMinimumWidth());
            // Check against our foreground's minimum height and width
            android.graphics.drawable.Drawable drawable = getForeground();
            if (drawable != null)
            {
                maxHeight = System.Math.Max(maxHeight, drawable.getMinimumHeight());
                maxWidth  = System.Math.Max(maxWidth, drawable.getMinimumWidth());
            }
            setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, childState),
                                 resolveSizeAndState(maxHeight, heightMeasureSpec, childState << MEASURED_HEIGHT_STATE_SHIFT
                                                     ));
            count = mMatchParentChildren.size();
            if (count > 1)
            {
                {
                    for (int i_1 = 0; i_1 < count; i_1++)
                    {
                        android.view.View child = mMatchParentChildren.get(i_1);
                        android.view.ViewGroup.MarginLayoutParams lp = (android.view.ViewGroup.MarginLayoutParams
                                                                        )child.getLayoutParams();
                        int childWidthMeasureSpec;
                        int childHeightMeasureSpec;
                        if (lp.width == android.view.ViewGroup.LayoutParams.MATCH_PARENT)
                        {
                            childWidthMeasureSpec = android.view.View.MeasureSpec.makeMeasureSpec(getMeasuredWidth
                                                                                                      () - getPaddingLeftWithForeground() - getPaddingRightWithForeground() - lp.leftMargin
                                                                                                  - lp.rightMargin, android.view.View.MeasureSpec.EXACTLY);
                        }
                        else
                        {
                            childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec, getPaddingLeftWithForeground
                                                                            () + getPaddingRightWithForeground() + lp.leftMargin + lp.rightMargin, lp.width);
                        }
                        if (lp.height == android.view.ViewGroup.LayoutParams.MATCH_PARENT)
                        {
                            childHeightMeasureSpec = android.view.View.MeasureSpec.makeMeasureSpec(getMeasuredHeight
                                                                                                       () - getPaddingTopWithForeground() - getPaddingBottomWithForeground() - lp.topMargin
                                                                                                   - lp.bottomMargin, android.view.View.MeasureSpec.EXACTLY);
                        }
                        else
                        {
                            childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec, getPaddingTopWithForeground
                                                                             () + getPaddingBottomWithForeground() + lp.topMargin + lp.bottomMargin, lp.height
                                                                         );
                        }
                        child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
                    }
                }
            }
        }