Пример #1
0
 protected internal override void onLayout(bool changed, int l, int t, int r, int
                                           b)
 {
     int count = getChildCount();
     {
         for (int i = 0; i < count; i++)
         {
             android.view.View child = getChildAt(i);
             if (child.getVisibility() != GONE)
             {
                 android.widget.AbsoluteLayout.LayoutParams lp = (android.widget.AbsoluteLayout.LayoutParams
                                                                  )child.getLayoutParams();
                 int childLeft = mPaddingLeft + lp.x;
                 int childTop  = mPaddingTop + lp.y;
                 child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop
                              + child.getMeasuredHeight());
             }
         }
     }
 }
Пример #2
0
        protected internal override void onMeasure(int widthMeasureSpec, int heightMeasureSpec
                                                   )
        {
            int count     = getChildCount();
            int maxHeight = 0;
            int maxWidth  = 0;

            // Find out how big everyone wants to be
            measureChildren(widthMeasureSpec, heightMeasureSpec);
            {
                // Find rightmost and bottom-most child
                for (int i = 0; i < count; i++)
                {
                    android.view.View child = getChildAt(i);
                    if (child.getVisibility() != GONE)
                    {
                        int childRight;
                        int childBottom;
                        android.widget.AbsoluteLayout.LayoutParams lp = (android.widget.AbsoluteLayout.LayoutParams
                                                                         )child.getLayoutParams();
                        childRight  = lp.x + child.getMeasuredWidth();
                        childBottom = lp.y + child.getMeasuredHeight();
                        maxWidth    = System.Math.Max(maxWidth, childRight);
                        maxHeight   = System.Math.Max(maxHeight, childBottom);
                    }
                }
            }
            // Account for padding too
            maxWidth  += mPaddingLeft + mPaddingRight;
            maxHeight += mPaddingTop + mPaddingBottom;
            // Check against minimum height and width
            maxHeight = System.Math.Max(maxHeight, getSuggestedMinimumHeight());
            maxWidth  = System.Math.Max(maxWidth, getSuggestedMinimumWidth());
            setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, 0), resolveSizeAndState
                                     (maxHeight, heightMeasureSpec, 0));
        }