Exemple #1
0
        protected internal override void onLayout(bool changed, int l, int t, int r, int
                                                  b)
        {
            int x             = getPaddingLeft();
            int y             = getPaddingTop();
            int contentHeight = b - t - getPaddingTop() - getPaddingBottom();

            if (mClose != null && mClose.getVisibility() != GONE)
            {
                android.view.ViewGroup.MarginLayoutParams lp = (android.view.ViewGroup.MarginLayoutParams
                                                                )mClose.getLayoutParams();
                x += lp.leftMargin;
                x += positionChild(mClose, x, y, contentHeight);
                x += lp.rightMargin;
                if (mAnimateInOnLayout)
                {
                    mAnimationMode    = ANIMATE_IN;
                    mCurrentAnimation = makeInAnimation();
                    mCurrentAnimation.start();
                    mAnimateInOnLayout = false;
                }
            }
            if (mTitleLayout != null && mCustomView == null)
            {
                x += positionChild(mTitleLayout, x, y, contentHeight);
            }
            if (mCustomView != null)
            {
                x += positionChild(mCustomView, x, y, contentHeight);
            }
            x = r - l - getPaddingRight();
            if (mMenuView != null)
            {
                x -= positionChildInverse(mMenuView, x, y, contentHeight);
            }
        }
Exemple #2
0
 public LayoutParams(android.view.ViewGroup.MarginLayoutParams arg0)  : base(global::MonoJavaBridge.JNIEnv.ThreadEnv)
 {
     global::MonoJavaBridge.JNIEnv         @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     global::MonoJavaBridge.JniLocalHandle handle = @__env.NewObject(android.widget.RelativeLayout.LayoutParams.staticClass, global::android.widget.RelativeLayout.LayoutParams._LayoutParams11759, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0));
     Init(@__env, handle);
 }
Exemple #3
0
 /// <summary><inheritDoc></inheritDoc></summary>
 public LayoutParams(android.view.ViewGroup.MarginLayoutParams source) : base(source
                                                                              )
 {
 }
Exemple #4
0
        protected internal override void onMeasure(int widthMeasureSpec, int heightMeasureSpec
                                                   )
        {
            int widthMode = android.view.View.MeasureSpec.getMode(widthMeasureSpec);

            if (widthMode != android.view.View.MeasureSpec.EXACTLY)
            {
                throw new System.InvalidOperationException(GetType().Name + " can only be used "
                                                           + "with android:layout_width=\"match_parent\" (or fill_parent)");
            }
            int heightMode = android.view.View.MeasureSpec.getMode(heightMeasureSpec);

            if (heightMode == android.view.View.MeasureSpec.UNSPECIFIED)
            {
                throw new System.InvalidOperationException(GetType().Name + " can only be used "
                                                           + "with android:layout_height=\"wrap_content\"");
            }
            int contentWidth = android.view.View.MeasureSpec.getSize(widthMeasureSpec);
            int maxHeight    = mContentHeight > 0 ? mContentHeight : android.view.View.MeasureSpec
                               .getSize(heightMeasureSpec);
            int verticalPadding = getPaddingTop() + getPaddingBottom();
            int availableWidth  = contentWidth - getPaddingLeft() - getPaddingRight();
            int height          = maxHeight - verticalPadding;
            int childSpecHeight = android.view.View.MeasureSpec.makeMeasureSpec(height, android.view.View
                                                                                .MeasureSpec.AT_MOST);

            if (mClose != null)
            {
                availableWidth = measureChildView(mClose, availableWidth, childSpecHeight, 0);
                android.view.ViewGroup.MarginLayoutParams lp = (android.view.ViewGroup.MarginLayoutParams
                                                                )mClose.getLayoutParams();
                availableWidth -= lp.leftMargin + lp.rightMargin;
            }
            if (mMenuView != null && mMenuView.getParent() == this)
            {
                availableWidth = measureChildView(mMenuView, availableWidth, childSpecHeight, 0);
            }
            if (mTitleLayout != null && mCustomView == null)
            {
                availableWidth = measureChildView(mTitleLayout, availableWidth, childSpecHeight,
                                                  0);
            }
            if (mCustomView != null)
            {
                android.view.ViewGroup.LayoutParams lp = mCustomView.getLayoutParams();
                int customWidthMode = lp.width != android.view.ViewGroup.LayoutParams.WRAP_CONTENT
                                         ? android.view.View.MeasureSpec.EXACTLY : android.view.View.MeasureSpec.AT_MOST;
                int customWidth      = lp.width >= 0 ? System.Math.Min(lp.width, availableWidth) : availableWidth;
                int customHeightMode = lp.height != android.view.ViewGroup.LayoutParams.WRAP_CONTENT
                                         ? android.view.View.MeasureSpec.EXACTLY : android.view.View.MeasureSpec.AT_MOST;
                int customHeight = lp.height >= 0 ? System.Math.Min(lp.height, height) : height;
                mCustomView.measure(android.view.View.MeasureSpec.makeMeasureSpec(customWidth, customWidthMode
                                                                                  ), android.view.View.MeasureSpec.makeMeasureSpec(customHeight, customHeightMode)
                                    );
            }
            if (mContentHeight <= 0)
            {
                int measuredHeight = 0;
                int count          = getChildCount();
                {
                    for (int i = 0; i < count; i++)
                    {
                        android.view.View v  = getChildAt(i);
                        int paddedViewHeight = v.getMeasuredHeight() + verticalPadding;
                        if (paddedViewHeight > measuredHeight)
                        {
                            measuredHeight = paddedViewHeight;
                        }
                    }
                }
                setMeasuredDimension(contentWidth, measuredHeight);
            }
            else
            {
                setMeasuredDimension(contentWidth, maxHeight);
            }
        }
Exemple #5
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);
                    }
                }
            }
        }