Пример #1
0
        public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (_shellContent != null)
            {
                _page = ((IShellContentController)_shellContent).GetOrCreateContent();
            }

            _root = inflater.Inflate(Resource.Layout.ShellContent, null).JavaCast <CoordinatorLayout>();

            var scrollview = _root.FindViewById <NestedScrollView>(Resource.Id.shellcontent_scrollview);

            _toolbar = _root.FindViewById <Toolbar>(Resource.Id.shellcontent_toolbar);

            _renderer = Platform.CreateRenderer(_page, Context);
            Platform.SetRenderer(_page, _renderer);

            _shellPageContainer = new ShellPageContainer(Context, _renderer);

            scrollview.AddView(_shellPageContainer);

            _toolbarTracker      = _shellContext.CreateTrackerForToolbar(_toolbar);
            _toolbarTracker.Page = _page;
            // this is probably not the most ideal way to do that
            _toolbarTracker.CanNavigateBack = _shellContent == null;

            _appearanceTracker = _shellContext.CreateToolbarAppearanceTracker();

            ((IShellController)_shellContext.Shell).AddAppearanceObserver(this, _page);

            return(_root);
        }
Пример #2
0
        public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (_shellContent != null)
            {
                _page = ((IShellContentController)_shellContent).GetOrCreateContent();
            }

            _root = inflater.Inflate(Resource.Layout.ShellContent, null).JavaCast <CoordinatorLayout>();

            _toolbar = _root.FindViewById <Toolbar>(Resource.Id.shellcontent_toolbar);

            _renderer = AppCompat.Platform.CreateRenderer(_page, Context);
            AppCompat.Platform.SetRenderer(_page, _renderer);

            _shellPageContainer = new ShellPageContainer(Context, _renderer);

            if (_root is ViewGroup vg)
            {
                vg.AddView(_shellPageContainer);
            }

            _toolbarTracker      = _shellContext.CreateTrackerForToolbar(_toolbar);
            _toolbarTracker.Page = _page;
            // this is probably not the most ideal way to do that
            _toolbarTracker.CanNavigateBack = _shellContent == null;

            _appearanceTracker = _shellContext.CreateToolbarAppearanceTracker();

            ((IShellController)_shellContext.Shell).AddAppearanceObserver(this, _page);

            if (_shellPageContainer.LayoutParameters is CoordinatorLayout.LayoutParams layoutParams)
            {
                layoutParams.Behavior = new AppBarLayout.ScrollingViewBehavior();
            }

            return(_root);
        }