示例#1
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            int width  = r - l;
            int height = b - t;

            var context = Context;

            _bottomNavigationView.Measure(MeasureSpec.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpec.MakeMeasureSpec(height, MeasureSpecMode.AtMost));
            int tabsHeight = Math.Min(height, Math.Max(_bottomNavigationView.MeasuredHeight, _bottomNavigationView.MinimumHeight));

            if (width > 0 && height > 0)
            {
                _pageController.ContainerArea = new Rectangle(0, 0, context.FromPixels(width), context.FromPixels(_frameLayout.Height));
                ObservableCollection <Element> internalChildren = _pageController.InternalChildren;

                for (var i = 0; i < internalChildren.Count; i++)
                {
                    var child = internalChildren[i] as VisualElement;

                    if (child == null)
                    {
                        continue;
                    }

                    NavigationPageRenderer navigationRenderer;
                    using (IVisualElementRenderer renderer = Platform.Android.Platform.GetRenderer(child))
                    {
                        navigationRenderer = renderer as NavigationPageRenderer;
                    }

                    if (navigationRenderer != null)
                    {
                        // navigationRenderer.ContainerPadding = tabsHeight;
                    }
                }

                _bottomNavigationView.Measure(MeasureSpec.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpec.MakeMeasureSpec(tabsHeight, MeasureSpecMode.Exactly));
                _bottomNavigationView.Layout(0, 0, width, tabsHeight);
            }

            base.OnLayout(changed, l, t, r, b);
        }
示例#2
0
        private void SetupLargeTab()
        {
            var tabBar = (CustomTabBar)ShellItem;

            bottomView.Measure((int)MeasureSpecMode.Unspecified, (int)MeasureSpecMode.Unspecified);

            outerlayout.Measure((int)MeasureSpecMode.Unspecified, (int)MeasureSpecMode.Unspecified);

            shellOverlay.RemoveAllViews();
            shellOverlay.AddView(ConvertFormsToNative(tabBar.TabBarView,
                                                      new Xamarin.Forms.Rectangle(0, 0, Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Width / Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Density, (double)bottomView?.MeasuredHeight / Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Density)));
            // If I do not hide navigation bar, I have to use Resources.DisplayMetrics.WidthPixels (instead of DeviceDisplay.MainDisplayInfo.Width) because I want the width of the screen without the height of the navigation bar.
        }
示例#3
0
        private async void SetupLargeTab()
        {
            var todoTabBar = (TodoTabBar)ShellItem;
            var layout     = new FrameLayout(Context);

            var    imageHandler = todoTabBar.LargeTab.Icon.GetHandler();
            Bitmap bitmap       = await imageHandler.LoadImageAsync(todoTabBar.LargeTab.Icon, Context);

            var image = new ImageView(Context);

            image.SetImageBitmap(bitmap);

            layout.AddView(image);

            var lp = new FrameLayout.LayoutParams(300, 300);

            _bottomView.Measure((int)MeasureSpecMode.Unspecified, (int)MeasureSpecMode.Unspecified);
            lp.BottomMargin = _bottomView.MeasuredHeight / 2;

            layout.LayoutParameters = lp;

            _shellOverlay.RemoveAllViews();
            _shellOverlay.AddView(layout);
        }