コード例 #1
0
        protected override void onLayout(CGRect newPosition, bool parentHidden)
        {
            // Make room for padding
            newPosition = newPosition.ApplyInsets(Padding);

            if (!parentHidden && Visible)
            {
                // Position each view according to it's gravity
                foreach (var v in SubViews)
                {
                    if (v.Gone)
                    {
                        v.Layout(CGRect.Empty, false);
                        continue;
                    }

                    // If subview has a gravity specified, use it, otherwise use our own
                    var g = v.LayoutParameters.Gravity;
                    if (g == Gravity.None)
                    {
                        g = this.Gravity;
                    }

                    // Get it's size
                    var size = v.GetMeasuredSize();

                    // Work out it's position by apply margins and gravity
                    var subViewPosition = newPosition.ApplyInsets(v.LayoutParameters.Margins).ApplyGravity(size, g);

                    // Position it
                    v.Layout(subViewPosition, false);
                }
            }
        }
コード例 #2
0
ファイル: FrameLayout.cs プロジェクト: Shaddix/XibFree
        protected override void onLayout(CGRect newPosition, bool parentHidden)
        {
            // Make room for padding
            newPosition = newPosition.ApplyInsets(Padding);

            if (!parentHidden && Visible)
            {
                // Position each view according to it's gravity
                foreach (var v in SubViews)
                {
                    if (v.Gone)
                    {
                        v.Layout(CGRect.Empty, false);
                        continue;
                    }

                    // If subview has a gravity specified, use it, otherwise use our own
                    var g = v.LayoutParameters.Gravity;
                    if (g==Gravity.None)
                    {
                        g = this.Gravity;
                    }

                    // Get it's size
                    var size = v.GetMeasuredSize();

                    // Work out it's position by apply margins and gravity
                    var subViewPosition = newPosition.ApplyInsets(v.LayoutParameters.Margins).ApplyGravity(size, g);

                    // Position it
                    v.Layout(subViewPosition, false);
                }
            }

            HideSubviewsIfNeeded(parentHidden);
        }