コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_main);

            ConstraintLayout          constraintLayout = FindViewById <ConstraintLayout>(Resource.Id.bottomSheet);
            AnchorBottomSheetBehavior behavior         = AnchorBottomSheetBehavior.From(constraintLayout);

            int   hPx = Resources.DisplayMetrics.HeightPixels;
            float cardAnchorSizeDp = 270 + 20;
            float cardAnchorSizePx = PxFromDp(this, cardAnchorSizeDp);

            int anchor = hPx - (int)cardAnchorSizePx;

            behavior.AnchorOffset = anchor;
        }
コード例 #2
0
        public void SetElement(VisualElement element)
        {
            MasterDetailPage oldElement = _page;

            _page = element as MasterDetailPage;


            _detailLayout = new MasterDetailContainer(_page, false, Context)
            {
                LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent)
            };

            var parameters = new CoordinatorLayout.LayoutParams(new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent)
            {
                Gravity = (int)GravityFlags.Start
            });

            parameters.Behavior = new AnchorBottomSheetBehavior();

            _masterLayout = new MasterDetailContainer(_page, true, Context)
            {
                LayoutParameters = parameters,
            };
            _masterLayout.RequestLayout();
            AddView(_detailLayout);

            AddView(_masterLayout);
            behaviour             = AnchorBottomSheetBehavior.From(_masterLayout);
            behaviour.PeekHeight  = (int)(NowPlayingPage.TotalMiniBarHeight * Android.NGraphicsExtensions.Scale);
            behaviour.DragChanged = (percent) =>
            {
                var panel = _page as SlideUpPanel;
                if (panel != null)
                {
                    panel.PercentVisible = (float)percent;
                }
            };


            var activity = Context as Activity;

            //activity.ActionBar.SetDisplayShowHomeEnabled(true);
            //activity.ActionBar.SetHomeButtonEnabled(true);

            UpdateBackgroundColor(_page);
            UpdateBackgroundImage(_page);

            OnElementChanged(oldElement, element);

            if (oldElement != null)
            {
                ((IMasterDetailPageController)oldElement).BackButtonPressed -= OnBackButtonPressed;
            }

            if (_page != null)
            {
                MasterDetailPageController.BackButtonPressed += OnBackButtonPressed;
            }

            if (Tracker == null)
            {
                Tracker = new VisualElementTracker(this);
            }

            _page.PropertyChanged += HandlePropertyChanged;
            _page.Appearing       += MasterDetailPageAppearing;
            _page.Disappearing    += MasterDetailPageDisappearing;

            UpdateMaster();
            UpdateDetail();

            //Device.Info.PropertyChanged += DeviceInfoPropertyChanged;
            SetGestureState();

            Presented = _page.IsPresented;

            //AddDrawerListener(this);

            //if (element != null)
            //	element.SendViewInitialized(this);

            if (element != null && !string.IsNullOrEmpty(element.AutomationId))
            {
                ContentDescription = element.AutomationId;
            }
        }