Ejemplo n.º 1
0
 private android.view.View obtainView()
 {
     android.view.View child = mFactory.makeView();
     android.widget.FrameLayout.LayoutParams lp = (android.widget.FrameLayout.LayoutParams
                                                   )child.getLayoutParams();
     if (lp == null)
     {
         lp = new android.widget.FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams
                                                          .MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
     }
     addView(child, lp);
     return(child);
 }
Ejemplo n.º 2
0
		private android.view.View obtainView()
		{
			android.view.View child = mFactory.makeView();
			android.widget.FrameLayout.LayoutParams lp = (android.widget.FrameLayout.LayoutParams
				)child.getLayoutParams();
			if (lp == null)
			{
				lp = new android.widget.FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams
					.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
			}
			addView(child, lp);
			return child;
		}
Ejemplo n.º 3
0
        protected internal override void onMeasure(int widthMeasureSpec, int heightMeasureSpec
                                                   )
        {
            base.onMeasure(widthMeasureSpec, heightMeasureSpec);
            if (mActionBarView == null)
            {
                return;
            }
            android.widget.FrameLayout.LayoutParams lp = (android.widget.FrameLayout.LayoutParams
                                                          )mActionBarView.getLayoutParams();
            int actionBarViewHeight = mActionBarView.isCollapsed() ? 0 : mActionBarView.getMeasuredHeight
                                          () + lp.topMargin + lp.bottomMargin;

            if (mTabContainer != null && mTabContainer.getVisibility() != GONE)
            {
                int mode = android.view.View.MeasureSpec.getMode(heightMeasureSpec);
                if (mode == android.view.View.MeasureSpec.AT_MOST)
                {
                    int maxHeight = android.view.View.MeasureSpec.getSize(heightMeasureSpec);
                    setMeasuredDimension(getMeasuredWidth(), System.Math.Min(actionBarViewHeight + mTabContainer
                                                                             .getMeasuredHeight(), maxHeight));
                }
            }
        }
Ejemplo n.º 4
0
		/// <summary>
		/// <p>Prepare the popup by embedding in into a new ViewGroup if the
		/// background drawable is not null.
		/// </summary>
		/// <remarks>
		/// <p>Prepare the popup by embedding in into a new ViewGroup if the
		/// background drawable is not null. If embedding is required, the layout
		/// parameters' height is mnodified to take into account the background's
		/// padding.</p>
		/// </remarks>
		/// <param name="p">the layout parameters of the popup's content view</param>
		private void preparePopup(android.view.WindowManagerClass.LayoutParams p)
		{
			if (mContentView == null || mContext == null || mWindowManager == null)
			{
				throw new System.InvalidOperationException("You must specify a valid content view by "
					 + "calling setContentView() before attempting to show the popup.");
			}
			if (mBackground != null)
			{
				android.view.ViewGroup.LayoutParams layoutParams = mContentView.getLayoutParams();
				int height = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
				if (layoutParams != null && layoutParams.height == android.view.ViewGroup.LayoutParams
					.WRAP_CONTENT)
				{
					height = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
				}
				// when a background is available, we embed the content view
				// within another view that owns the background drawable
				android.widget.PopupWindow.PopupViewContainer popupViewContainer = new android.widget.PopupWindow
					.PopupViewContainer(this, mContext);
				android.widget.FrameLayout.LayoutParams listParams = new android.widget.FrameLayout
					.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, height);
				popupViewContainer.setBackgroundDrawable(mBackground);
				popupViewContainer.addView(mContentView, listParams);
				mPopupView = popupViewContainer;
			}
			else
			{
				mPopupView = mContentView;
			}
			mPopupWidth = p.width;
			mPopupHeight = p.height;
		}
Ejemplo n.º 5
0
        protected internal override void onLayout(bool changed, int left, int top, int right
                                                  , int bottom)
        {
            int count        = getChildCount();
            int parentLeft   = getPaddingLeftWithForeground();
            int parentRight  = right - left - getPaddingRightWithForeground();
            int parentTop    = getPaddingTopWithForeground();
            int parentBottom = bottom - top - getPaddingBottomWithForeground();

            mForegroundBoundsChanged = true;
            {
                for (int i = 0; i < count; i++)
                {
                    android.view.View child = getChildAt(i);
                    if (child.getVisibility() != GONE)
                    {
                        android.widget.FrameLayout.LayoutParams lp = (android.widget.FrameLayout.LayoutParams
                                                                      )child.getLayoutParams();
                        int width  = child.getMeasuredWidth();
                        int height = child.getMeasuredHeight();
                        int childLeft;
                        int childTop;
                        int gravity = lp.gravity;
                        if (gravity == -1)
                        {
                            gravity = DEFAULT_CHILD_GRAVITY;
                        }
                        int layoutDirection = getResolvedLayoutDirection();
                        int absoluteGravity = android.view.Gravity.getAbsoluteGravity(gravity, layoutDirection
                                                                                      );
                        int verticalGravity = gravity & android.view.Gravity.VERTICAL_GRAVITY_MASK;
                        switch (absoluteGravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK)
                        {
                        case android.view.Gravity.LEFT:
                        {
                            childLeft = parentLeft + lp.leftMargin;
                            break;
                        }

                        case android.view.Gravity.CENTER_HORIZONTAL:
                        {
                            childLeft = parentLeft + (parentRight - parentLeft - width) / 2 + lp.leftMargin -
                                        lp.rightMargin;
                            break;
                        }

                        case android.view.Gravity.RIGHT:
                        {
                            childLeft = parentRight - width - lp.rightMargin;
                            break;
                        }

                        default:
                        {
                            childLeft = parentLeft + lp.leftMargin;
                            break;
                        }
                        }
                        switch (verticalGravity)
                        {
                        case android.view.Gravity.TOP:
                        {
                            childTop = parentTop + lp.topMargin;
                            break;
                        }

                        case android.view.Gravity.CENTER_VERTICAL:
                        {
                            childTop = parentTop + (parentBottom - parentTop - height) / 2 + lp.topMargin - lp
                                       .bottomMargin;
                            break;
                        }

                        case android.view.Gravity.BOTTOM:
                        {
                            childTop = parentBottom - height - lp.bottomMargin;
                            break;
                        }

                        default:
                        {
                            childTop = parentTop + lp.topMargin;
                            break;
                        }
                        }
                        child.layout(childLeft, childTop, childLeft + width, childTop + height);
                    }
                }
            }
        }
Ejemplo n.º 6
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);
                    }
                }
            }
        }