コード例 #1
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            if (changed && ChildCount > 0)
            {
                Android.Views.View child = GetChildAt(0);

                int width  = r - l;
                int height = b - t;

                int previewWidth  = width;
                int previewHeight = height;
                if (mPreviewSize != null)
                {
                    previewWidth  = mPreviewSize.Width;
                    previewHeight = mPreviewSize.Height;
                }

                // Center the child SurfaceView within the parent.
                if (width * previewHeight > height * previewWidth)
                {
                    int scaledChildWidth = previewWidth * height / previewHeight;
                    child.Layout((width - scaledChildWidth) / 2, 0,
                                 (width + scaledChildWidth) / 2, height);
                }
                else
                {
                    int scaledChildHeight = previewHeight * width / previewWidth;
                    child.Layout(0, (height - scaledChildHeight) / 2,
                                 width, (height + scaledChildHeight) / 2);
                }
            }
        }
コード例 #2
0
        void UpdateContentLayout()
        {
            VisualElement mauiControlsView = View as VisualElement;
            AView         aview            = Content.ToPlatform();

            if (mauiControlsView == null || aview == null)
            {
                return;
            }

            var x      = (int)Context.ToPixels(mauiControlsView.X);
            var y      = (int)Context.ToPixels(mauiControlsView.Y);
            var width  = Math.Max(0, (int)Context.ToPixels(mauiControlsView.Width));
            var height = Math.Max(0, (int)Context.ToPixels(mauiControlsView.Height));

            aview.Layout(x, y, width, height);

            if ((aview is LayoutViewGroup || aview is ContentViewGroup || aview is CoordinatorLayout || aview is FragmentContainerView) && width == 0 && height == 0)
            {
                // Nothing to do here; just chill.
            }
            else
            {
                aview.Measure(MeasureSpecMode.Exactly.MakeMeasureSpec(width), MeasureSpecMode.Exactly.MakeMeasureSpec(height));
                aview.Layout(x, y, x + width, y + height);
            }
        }
コード例 #3
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            AToolbar bar = _toolbar;

            // make sure bar stays on top of everything
            bar.BringToFront();

            base.OnLayout(changed, l, t, r, b);

            int barHeight = ActionBarHeight();

            if (barHeight != _lastActionBarHeight && _lastActionBarHeight > 0)
            {
                ResetToolbar();
                bar = _toolbar;
            }
            _lastActionBarHeight = barHeight;

            bar.Measure(MeasureSpecFactory.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(barHeight, MeasureSpecMode.Exactly));

            int internalHeight  = b - t - barHeight;
            int containerHeight = ToolbarVisible ? internalHeight : b - t;

            containerHeight -= ContainerPadding;

            Element.ContainerArea = new Rectangle(0, 0, Context.FromPixels(r - l), Context.FromPixels(containerHeight));
            // Potential for optimization here, the exact conditions by which you don't need to do this are complex
            // and the cost of doing when it's not needed is moderate to low since the layout will short circuit pretty fast
            Element.ForceLayout();

            for (var i = 0; i < ChildCount; i++)
            {
                AView child = GetChildAt(i);
                bool  isBar = JNIEnv.IsSameObject(child.Handle, bar.Handle);

                if (ToolbarVisible)
                {
                    if (isBar)
                    {
                        bar.Layout(0, 0, r - l, barHeight);
                    }
                    else
                    {
                        child.Layout(0, barHeight + ContainerPadding, r, b);
                    }
                }
                else
                {
                    if (isBar)
                    {
                        bar.Layout(0, -1000, r, barHeight - 1000);
                    }
                    else
                    {
                        child.Layout(0, ContainerPadding, r, b);
                    }
                }
            }
        }
コード例 #4
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            var navigationPage = Element as NavigationPage;

            if (navigationPage.BarBackgroundColor != Color.Transparent)
            {
                if (navigationPage.CurrentPage.GetType() != typeof(PetProfilePage))
                {
                    base.OnLayout(changed, l, t + ActionBarHeight(), r, b + ActionBarHeight());
                }
            }
            else
            {
                base.OnLayout(changed, l, t, r, b + ActionBarHeight());
            }

            AToolbar bar = _toolbar;

            bar.BringToFront();

            for (var i = 0; i < ChildCount; i++)
            {
                AView child = GetChildAt(i);

                var  pageContainer = child.GetType().GetProperty("Child")?.GetValue(child) as IVisualElementRenderer;
                Page childPage     = pageContainer?.Element as Page;

                if (childPage == null)
                {
                    return;
                }

                bool childHasNavBar = NavigationPage.GetHasNavigationBar(childPage);

                if (childHasNavBar)
                {
                    if (navigationPage.BarBackgroundColor != Color.Transparent)
                    {
                        if (navigationPage.CurrentPage.GetType() != typeof(PetProfilePage))
                        {
                            child.Layout(0, ActionBarHeight(), r, b + ActionBarHeight());
                        }
                    }
                    else
                    {
                        child.Layout(0, 0, r, b + ActionBarHeight());
                    }
                }
            }
        }
コード例 #5
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            if (CustomNavigationPage.CurrentPage == CustomNavigationPage.FirstPage)
            {
                CustomNavigationPage.IsFirstPage        = true;
                CustomNavigationPage.IgnoreLayoutChange = false;
                base.OnLayout(changed, l, t, r, b);
                return;
            }

            CustomNavigationPage.IsFirstPage        = false;
            CustomNavigationPage.IgnoreLayoutChange = true;
            base.OnLayout(changed, l, t, r, b);
            CustomNavigationPage.IgnoreLayoutChange = false;

            int containerHeight = b - t;

            PageController.ContainerArea = new Rectangle(0, 0, Context.FromPixels(r - l), Context.FromPixels(containerHeight));

            for (var i = 0; i < ChildCount; i++)
            {
                AView child = GetChildAt(i);

                if (child is Android.Support.V7.Widget.Toolbar)
                {
                    continue;
                }

                child.Layout(0, 0, r, b);
            }
        }
コード例 #6
0
ファイル: exDragGame.cs プロジェクト: kbyang/PhoneApp
 public bool OnTouch(View v, MotionEvent e)
 {
     switch (e.Action)
     {
     case MotionEventActions.Down:
         _viewX = e.GetX ();
         _viewY = e.GetY ();
         break;
     case MotionEventActions.Move:
         var left = (int)(e.RawX - _viewX);
         var right = (int)(left + v.Width);
         var top = (int)(e.RawY - _viewY);
         var bottom = (int)(v.Height + top);
         Console.WriteLine (left);
         Console.WriteLine (v.Width);
         if (left == v.Width-40) {
         //					TextView tv=new TextView(GetApplicationContext());
         //					tv.SetText("Avoided call with ex!");
         //					Resource.Layout.exDragGame   AddView(tv);
             Console.WriteLine ("hit the edge");
         }
         v.Layout (left, top, right, bottom);
         //				Console.WriteLine (" L " + left + " R " + right + " T " + top + " B " + bottom);
         break;
     }
     return true;
 }
コード例 #7
0
        public static Bitmap ToBitmap(this AView view)
        {
            var layout = new FrameLayout(view.Context);

            layout.LayoutParameters = new FrameLayout.LayoutParams(500, 500);
            view.LayoutParameters   = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WrapContent, FrameLayout.LayoutParams.WrapContent)
            {
                Gravity = GravityFlags.Center
            };

            layout.AddView(view);
            layout.Measure(500, 500);
            layout.Layout(0, 0, 500, 500);

            var act      = view.Context.GetActivity();
            var rootView = act.FindViewById <FrameLayout>(Android.Resource.Id.Content);

            rootView.AddView(layout);

            var    bitmap = Bitmap.CreateBitmap(view.Width, view.Height, Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas(bitmap);

            view.Layout(0, 0, view.Width, view.Height);
            view.Draw(canvas);

            rootView.RemoveView(layout);

            return(bitmap);
        }
コード例 #8
0
        protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
        {
            using (var h = new Handler(Looper.MainLooper))
            {
                h.Post(() =>
                {
                    double width  = base.Context.FromPixels((double)(right - left));
                    double height = base.Context.FromPixels((double)(bottom - top));
                    var size      = new Xamarin.Forms.Size(width, height);

                    var msw = MeasureSpec.MakeMeasureSpec(right - left, MeasureSpecMode.Exactly);
                    var msh = MeasureSpec.MakeMeasureSpec(bottom - top, MeasureSpecMode.Exactly);
                    _nativeView.Measure(msw, msh);
                    _nativeView.Layout(0, 0, right - left, bottom - top);

                    if (size != _previousSize || !_isLaidOut)
                    {
                        if (_viewCell.View is Layout layout)
                        {
                            layout.Layout(new Rectangle(0, 0, width, height));

                            //Doesn't appear to be necessary?
                            //layout.ForceLayout();
                            //FixChildLayouts(layout);


                            _isLaidOut = true;
                        }
                    }

                    _previousSize = size;
                });
            }
        }
コード例 #9
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);

            //if (changed)
            {
                //var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly);
                if (actionBarCustomView != null)
                {
                    var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly);

                    AddCustomMenuView();

                    int x2 = r - l;
                    if (msw <= 0)
                    {
                        msw = (int)Globals.ScreenWidth;
                    }
                    if (x2 <= 0)
                    {
                        x2 = (int)Globals.ScreenWidth;
                    }

                    actionBarCustomView.Measure(msw, BaseUIHelper.ConvertDPToPixels(50));     //MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly));
                    actionBarCustomView.Layout(0, 0, x2, BaseUIHelper.ConvertDPToPixels(50)); //b - t);

                    actionBarCustomView.Visibility = ViewStates.Visible;
                }
            }
        }
コード例 #10
0
ファイル: DroidFactory.cs プロジェクト: Zebra/iFactr-Android
        public static Bitmap LoadBitmapFromView(View v)
        {
            var b = Bitmap.CreateBitmap(v.Width, v.Height, Bitmap.Config.Argb8888);
            var c = new Canvas(b);

            v.Layout(0, 0, v.LayoutParameters.Width, v.LayoutParameters.Height);
            v.Draw(c);
            return(b);
        }
コード例 #11
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);
            var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly);
            var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly);

            _view.Measure(msw, msh);
            _view.Layout(0, 0, r - l, b - t);
        }
コード例 #12
0
        public static Bitmap LoadBitmapFromView(Android.Views.View v)
        {
            Bitmap b = Bitmap.CreateBitmap(v.Width, v.Height, Bitmap.Config.Argb8888);
            Canvas c = new Canvas(b);

            v.Layout(0, 0, v.Width, v.Height);
            v.Draw(c);
            return(b);
        }
コード例 #13
0
        protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
        {
            //base.OnLayout(changed, left, top, right, bottom);
            var msw = MeasureSpec.MakeMeasureSpec(right - 1, MeasureSpecMode.Exactly);
            var msh = MeasureSpec.MakeMeasureSpec(bottom - 1, MeasureSpecMode.Exactly);

            //_view.Measure(right, bottom);
            _view.Measure(msw, msh);
            _view.Layout(0, 0, right, bottom - top);
        }
コード例 #14
0
        /**
	     * ´Óview µÃµ½Í¼Æ¬
	     * @param view
	     * @return
	     */
        public static Bitmap GetBitmapFromView(View view)
        {
            view.DestroyDrawingCache();
            view.Measure(View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified),
                View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified));
            view.Layout(0, 0, view.MeasuredWidth, view.MeasuredHeight);
            view.DrawingCacheEnabled = true;
            Bitmap bitmap = view.GetDrawingCache(true);
            return bitmap;
        }
コード例 #15
0
ファイル: Platform.cs プロジェクト: zmtzawqlp/maui
            protected override void OnLayout(bool changed, int l, int t, int r, int b)
            {
                if (changed)
                {
                    _modal.Layout(new Rectangle(0, 0, Context.FromPixels(r - l), Context.FromPixels(b - t)));
                    _backgroundView.Layout(0, 0, r - l, b - t);
                }

                _renderer.UpdateLayout();
            }
コード例 #16
0
        public Bitmap LayoutToBitmap(Android.Views.View markerLayout)
        {
            markerLayout.Measure(Android.Views.View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified), Android.Views.View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified));
            markerLayout.Layout(0, 0, markerLayout.MeasuredWidth, markerLayout.MeasuredHeight);
            Bitmap bitmap = Bitmap.CreateBitmap(markerLayout.MeasuredWidth, markerLayout.MeasuredHeight, Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas(bitmap);

            markerLayout.Draw(canvas);
            return(bitmap);
        }
コード例 #17
0
ファイル: PlatformTestFixture.cs プロジェクト: sung-su/maui
		protected void Layout(VisualElement element, AView nativeView)
		{
			var size = element.Measure(double.PositiveInfinity, double.PositiveInfinity, MeasureFlags.IncludeMargins);
			var width = size.Request.Width;
			var height = size.Request.Height;
			element.Layout(new Rect(0, 0, width, height));

			int widthSpec = AView.MeasureSpec.MakeMeasureSpec((int)width, MeasureSpecMode.Exactly);
			int heightSpec = AView.MeasureSpec.MakeMeasureSpec((int)height, MeasureSpecMode.Exactly);
			nativeView.Measure(widthSpec, heightSpec);
			nativeView.Layout(0, 0, (int)width, (int)height);
		}
コード例 #18
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);

            System.Diagnostics.Debug.WriteLine("CameraPageRenderer.OnLayout");

            var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly);
            var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly);

            view.Measure(msw, msh);
            view.Layout(0, 0, r - l, b - t);
        }
コード例 #19
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);
            var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly);
            var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly);

            _view.Measure(msw, msh);

            var y = (int)(_header != null ? _header.Bounds.Height * DeviceDisplay.MainDisplayInfo.Density : 0);

            _view.Layout(0, y, r - l, b - t);
        }
コード例 #20
0
ファイル: Platform.cs プロジェクト: typehm/Xamarin.Forms
            protected override void OnLayout(bool changed, int l, int t, int r, int b)
            {
                if (changed)
                {
                    var activity = (FormsAppCompatActivity)Context;

                    _modal.Layout(new Rectangle(0, 0, activity.FromPixels(r - l), activity.FromPixels(b - t)));
                    _backgroundView.Layout(0, 0, r - l, b - t);
                }

                _renderer.UpdateLayout();
            }
コード例 #21
0
        public Drawable GetThumb(int progress)
        {
            ((TextView)thumbView.FindViewById(Resource.Id.thumbText)).SetText(String.Format(control.ThumbTextFormat, progress), BufferType.Normal);

            thumbView.Measure((int)MeasureSpecMode.Unspecified, (int)MeasureSpecMode.Unspecified);
            Bitmap bitmap = Bitmap.CreateBitmap(thumbView.MeasuredWidth, thumbView.MeasuredHeight, Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas(bitmap);

            thumbView.Layout(0, 0, thumbView.MeasuredWidth, thumbView.MeasuredHeight);
            thumbView.Draw(canvas);

            return(new BitmapDrawable(Resources, bitmap));
        }
コード例 #22
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);

            var w = r - l;
            var h = b - t;

            var msw = MeasureSpec.MakeMeasureSpec(w, MeasureSpecMode.Exactly);
            var msh = MeasureSpec.MakeMeasureSpec(h, MeasureSpecMode.Exactly);

            view.Measure(msw, msh);
            view.Layout(0, 0, w, h);
        }
コード例 #23
0
        public void UpdateLayout()
        {
            Performance.Start(out string reference);

            VisualElement view  = _renderer.Element;
            AView         aview = _renderer.View;

            var headlessOffset = CompressedLayout.GetHeadlessOffset(view);
            var x      = (int)_context.ToPixels(view.X + headlessOffset.X);
            var y      = (int)_context.ToPixels(view.Y + headlessOffset.Y);
            var width  = Math.Max(0, (int)_context.ToPixels(view.Width));
            var height = Math.Max(0, (int)_context.ToPixels(view.Height));


            if (aview is FormsViewGroup formsViewGroup)
            {
                Performance.Start(reference, "MeasureAndLayout");
                formsViewGroup.MeasureAndLayout(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.Exactly), x, y, x + width, y + height);
                Performance.Stop(reference, "MeasureAndLayout");
            }
            else if (aview is LayoutViewGroup && width == 0 && height == 0)
            {
                // Nothing to do here; just chill.
            }
            else
            {
                Performance.Start(reference, "Measure");
                aview.Measure(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.Exactly));
                Performance.Stop(reference, "Measure");

                Performance.Start(reference, "Layout");
                aview.Layout(x, y, x + width, y + height);
                Performance.Stop(reference, "Layout");
            }

            // If we're running sufficiently new Android, we have to make sure to update the ClipBounds to
            // match the new size of the ViewGroup
            if ((int)Forms.SdkInt >= 18)
            {
                UpdateClipToBounds();
            }

            UpdateClip();

            Performance.Stop(reference);

            //On Width or Height changes, the anchors needs to be updated
            UpdateAnchorX();
            UpdateAnchorY();
        }
コード例 #24
0
        public static Bitmap ConvertViewToBitmap(Android.Views.View v)
        {
            v.SetLayerType(LayerType.Hardware, null);
            v.DrawingCacheEnabled = true;

            v.Measure(Android.Views.View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified), Android.Views.View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified));
            v.Layout(0, 0, v.MeasuredWidth, v.MeasuredHeight);

            v.BuildDrawingCache(true);
            Bitmap b = Bitmap.CreateBitmap(v.GetDrawingCache(true));

            v.DrawingCacheEnabled = false; // clear drawing cache
            return(b);
        }
コード例 #25
0
        public static Bitmap LoadBitmapFromView(Android.Views.View v)
        {
            if (v.MeasuredHeight <= 0)
            {
                v.Measure(50, 50);
                Bitmap b = Bitmap.CreateBitmap(v.MeasuredWidth, v.MeasuredHeight, Bitmap.Config.Argb8888);
                Canvas c = new Canvas(b);
                v.Layout(0, 0, v.MeasuredWidth, v.MeasuredHeight);
                v.Draw(c);

                return(b);
            }

            return(null);
        }
コード例 #26
0
 public bool OnTouch(View v, MotionEvent e)
 {
     switch (e.Action)
     {
         case MotionEventActions.Down:
             _viewX = e.GetX();
             break;
         case MotionEventActions.Move:
             var left = (int)(e.RawX - _viewX);
             var right = (int)(left + v.Width);
             v.Layout(left, v.Top, right, v.Bottom);
             break;
     }
     return true;
 }
コード例 #27
0
ファイル: WrapperView.cs プロジェクト: sung-su/maui
        protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
        {
            _borderView?.BringToFront();

            if (ChildCount == 0 || GetChildAt(0) is not AView child)
            {
                return;
            }

            var widthMeasureSpec  = MeasureSpecMode.Exactly.MakeMeasureSpec(right - left);
            var heightMeasureSpec = MeasureSpecMode.Exactly.MakeMeasureSpec(bottom - top);

            child.Measure(widthMeasureSpec, heightMeasureSpec);
            child.Layout(0, 0, child.MeasuredWidth, child.MeasuredHeight);
            _borderView?.Layout(0, 0, child.MeasuredWidth, child.MeasuredHeight);
        }
コード例 #28
0
        public void UpdateLayout()
        {
            var reference = Guid.NewGuid().ToString();

            Performance.Start(reference);

            VisualElement view  = _renderer.Element;
            AView         aview = _renderer.View;

            var headlessOffset = CompressedLayout.GetHeadlessOffset(view);
            var x      = (int)_context.ToPixels(view.X + headlessOffset.X);
            var y      = (int)_context.ToPixels(view.Y + headlessOffset.Y);
            var width  = Math.Max(0, (int)_context.ToPixels(view.Width));
            var height = Math.Max(0, (int)_context.ToPixels(view.Height));

            var formsViewGroup = aview as FormsViewGroup;

            if (formsViewGroup == null)
            {
                Performance.Start(reference, "Measure");
                aview.Measure(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.Exactly));
                Performance.Stop(reference, "Measure");

                Performance.Start(reference, "Layout");
                aview.Layout(x, y, x + width, y + height);
                Performance.Stop(reference, "Layout");
            }
            else
            {
                Performance.Start(reference, "MeasureAndLayout");
                formsViewGroup.MeasureAndLayout(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.Exactly), x, y, x + width, y + height);
                Performance.Stop(reference, "MeasureAndLayout");
            }

            // If we're running sufficiently new Android, we have to make sure to update the ClipBounds to
            // match the new size of the ViewGroup
            if ((int)Build.VERSION.SdkInt >= 18)
            {
                UpdateClipToBounds();
            }

            Performance.Stop(reference);

            //On Width or Height changes, the anchors needs to be updated
            UpdateAnchorX();
            UpdateAnchorY();
        }
コード例 #29
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);

            try
            {
                var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly);
                var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly);

                _View.Measure(msw, msh);
                _View.Layout(0, 0, r - l, b - t);
            }
            catch (Exception ex)
            {
                Console.WriteLine("DROID_SCAN | OnLayout error", ex);
            }
        }
コード例 #30
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);

            relativeLayout.Layout(0, 0, r, b);
            topTextView.Layout(0, 25, r, 65);

            var mswBP = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly);
            var mshBP = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly);

            barcodePicker.Measure(mswBP, mshBP);
            barcodePicker.Layout(0, 90, r - l, b - t);

            overlay.Layout(0, ((b / 2) + 40), r - l, b);
            bottomTextView.Layout(0, (b / 2) + 60, r - l, b - 100);
            qrImageView.Layout(0, (b / 2) + 100, r - l, b - 20);
        }
コード例 #31
0
        private void FixLayoutSize(ViewGroup parent, View view)
        {
            if (view != null)
            {
                //specs for parent (recycler view)
                var widthSpec  = View.MeasureSpec.MakeMeasureSpec(parent.Width, MeasureSpecMode.Exactly);
                var heightSpec = View.MeasureSpec.MakeMeasureSpec(parent.Height, MeasureSpecMode.Unspecified);

                //specs for children (headers)
                var childWidthSpec  = ViewGroup.GetChildMeasureSpec(widthSpec, parent.PaddingLeft + parent.PaddingRight, view.LayoutParameters?.Width ?? 0);
                var childHeightSpec = ViewGroup.GetChildMeasureSpec(heightSpec, parent.PaddingTop + parent.PaddingBottom, view.LayoutParameters?.Height ?? 0);

                view.Measure(childWidthSpec, childHeightSpec);

                _stickyHeaderHeight = view.MeasuredHeight;
                view.Layout(0, 0, view.MeasuredWidth, _stickyHeaderHeight);
            }
        }
コード例 #32
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);

            if (_androidLinearLayout != null)
            {
                var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly);
                var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly);

                _androidLinearLayout.Measure(msw, msh);
                _androidLinearLayout.Layout(0, 0, r - l, b - t);
                if (webView != null)
                {
                    webView.Measure(msw, msh);
                    webView.Layout(0, (int)toolbarHeight, r - l, b - t);
                }
            }
        }
コード例 #33
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);

            AToolbar bar = _toolbar;

            bar.BringToFront();


            //int barHeight = ActionBarHeight();

            //bar.Measure(MeasureSpecFactory.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(barHeight, MeasureSpecMode.Exactly));

            //var barOffset = ToolbarVisible ? barHeight : 0;
            //int containerHeight = b - t - ContainerPadding;

            //PageController.ContainerArea = new Rectangle(0, 0, Context.FromPixels(r - l), Context.FromPixels(containerHeight));

            for (var i = 0; i < ChildCount; i++)
            {
                AView child = GetChildAt(i);

                var  pageContainer = child.GetType().GetProperty("Child")?.GetValue(child) as IVisualElementRenderer;
                Page childPage     = pageContainer?.Element as Page;

                if (childPage == null)
                {
                    return;
                }

                // We need to base the layout of both the child and the bar on the presence of the NavBar on the child Page itself.
                // If we layout the bar based on ToolbarVisible, we get a white bar flashing at the top of the screen.
                // If we layout the child based on ToolbarVisible, we get a white bar flashing at the bottom of the screen.
                bool childHasNavBar = NavigationPage.GetHasNavigationBar(childPage);

                if (childHasNavBar)
                {
                    //bar.Layout(0, 0, r - l, barHeight);
                    child.Layout(0, 0, r, b);
                }
            }
        }
コード例 #34
0
ファイル: MainActivity.cs プロジェクト: Yi-shion/Xamarin
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            mContent = GetChildAt(1);
            if (mContent != null)
            {
                mContent.Layout(l, t, l + mContent.MeasuredWidth, t + mContent.MeasuredHeight);
            }

            int menuWidth = 0;
            View menu = GetChildAt(0);
            if (menu != null)
            {
                ViewGroup.LayoutParams layoutParams = menu.LayoutParameters;
                menuWidth = layoutParams.Width;
                menu.Layout(l - menuWidth, t, l, t + menu.MeasuredHeight);
            }
        }