private void ViewPagerLayotChange(object sender, View.LayoutChangeEventArgs e)
        {
            var styledAttributes = this.Theme.ObtainStyledAttributes(new int[] { Android.Resource.Attribute.ActionBarSize, Android.Resource.Attribute.ActionBarStyle });
            var mActionBarSize   = (int)styledAttributes.GetDimension(0, 0);

            styledAttributes.Recycle();

            rootLayout.SetPadding(0, mActionBarSize, 0, 0);
            SetViewPagerMargin();
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            if (this.pagerPage == null)
            {
                this.pagerPage = new ViewPagerPage()
                {
                    FragmentManager = this.FragmentManager
                };
                this.visualRoot.Child = pagerPage;
            }

            // this will start Navigation to first tab
            this.ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;

            var styledAttributes = this.Theme.ObtainStyledAttributes(new int[] { Android.Resource.Attribute.ActionBarSize, Android.Resource.Attribute.ActionBarStyle });
            var mActionBarSize   = (int)styledAttributes.GetDimension(0, 0);
            var actionbarStyleId = styledAttributes.GetResourceId(1, 0);

            styledAttributes.Recycle();

            styledAttributes = this.Theme.ObtainStyledAttributes(actionbarStyleId, new int[] { Android.Resource.Attribute.BackgroundStacked });
            var tabsBackground = styledAttributes.GetDrawable(0);

            styledAttributes.Recycle();

            rootLayout = new RootLayout(this);

            this.rootLayout.SetBackgroundDrawable(tabsBackground);

            rootLayout.SetPadding(0, mActionBarSize, 0, 0);
            this.Window.DecorView.RootView.ViewTreeObserver.AddOnGlobalLayoutListener(this);

            frameLayout             = new FrameLayout(this);
            frameLayout.Id          = this.fragmentPageFrameLayoutResourceId;
            frameLayout.Visibility  = ViewStates.Gone;
            rootLayout.SizeChanged += (s, e) => UpdateRootLayouts();
            this.pagerPage.ViewPager.LayoutChange += ViewPagerLayotChange;

            this.pagerPage.ViewPager.PageSelected += Pager_PageSelected;

            rootLayout.AddView(this.pagerPage.ViewPager, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));
            rootLayout.AddView(frameLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));

            this.SetContentView(rootLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            if (this.pagerPage == null)
            {
                this.pagerPage = new ViewPagerPage() { FragmentManager = this.FragmentManager };
                this.visualRoot.Child = pagerPage;
            }

            // this will start Navigation to first tab
            this.ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;

            var styledAttributes = this.Theme.ObtainStyledAttributes(new int[] { Android.Resource.Attribute.ActionBarSize, Android.Resource.Attribute.ActionBarStyle });
            var mActionBarSize = (int)styledAttributes.GetDimension(0, 0);
            var actionbarStyleId = styledAttributes.GetResourceId(1, 0);
            styledAttributes.Recycle();

            styledAttributes = this.Theme.ObtainStyledAttributes(actionbarStyleId, new int[] { Android.Resource.Attribute.BackgroundStacked });
            var tabsBackground = styledAttributes.GetDrawable(0);
            styledAttributes.Recycle();

            rootLayout = new RootLayout(this);

            this.rootLayout.SetBackgroundDrawable(tabsBackground);

            rootLayout.SetPadding(0, mActionBarSize, 0, 0);
            this.Window.DecorView.RootView.ViewTreeObserver.AddOnGlobalLayoutListener(this);

            frameLayout = new FrameLayout(this);
            frameLayout.Id = this.fragmentPageFrameLayoutResourceId;
            frameLayout.Visibility = ViewStates.Gone;
            rootLayout.SizeChanged += (s, e) => UpdateRootLayouts();
            this.pagerPage.ViewPager.LayoutChange += ViewPagerLayotChange;

            this.pagerPage.ViewPager.PageSelected += Pager_PageSelected;

            rootLayout.AddView(this.pagerPage.ViewPager, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));
            rootLayout.AddView(frameLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));

            this.SetContentView(rootLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));
        }