예제 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_bottom_sheet);

            var recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerview);

            mOffsetText = FindViewById <TextView>(Resource.Id.offsetText);
            mStateText  = FindViewById <TextView>(Resource.Id.stateText);

            Toolbar toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            //SetSupportActionBar(toolbar);

            var linearLayoutManager = new LinearLayoutManager(this)
            {
                AutoMeasureEnabled = true
            };

            ApplicationAdapter adapter = new ApplicationAdapter(this, listApplications(this));

            recyclerView.SetLayoutManager(linearLayoutManager);
            recyclerView.SetAdapter(adapter);

            FrameLayout parentThatHasBottomSheetBehavior = (FrameLayout)recyclerView.Parent.Parent;

            mBottomSheetBehavior = BottomSheetBehavior.From(parentThatHasBottomSheetBehavior);

            if (mBottomSheetBehavior != null)
            {
                SetStateText(this, new OnStateChangeEventArgs(mBottomSheetBehavior.State));

                var bttomCallback = new BottomSheetBehaviorOverride(SetOffsetText, SetStateText);

                mBottomSheetBehavior.SetBottomSheetCallback(bttomCallback);
            }

            View peekButton = FindViewById <View>(Resource.Id.peek_me);

            peekButton.Click += delegate {
                //Let's peek it, programmatically
                View peakView = FindViewById <View>(Resource.Id.drag_me);
                mBottomSheetBehavior.PeekHeight = peakView.Height;
                peakView.RequestLayout();
            };

            View modal = FindViewById <View>(Resource.Id.as_modal);

            modal.Click += delegate {
                BottomSheetDialogFragment bottomSheetDialogFragment = new CustomBottomSheetDialogFragment();
                bottomSheetDialogFragment.Show(SupportFragmentManager, bottomSheetDialogFragment.Tag);
            };
        }
        public override void SetupDialog(Dialog dialog, int style)
        {
            base.SetupDialog(dialog, style);

            View contentView = View.Inflate(Context, Resource.Layout.bottom_sheet_dialog_content_view, null);

            dialog.SetContentView(contentView);

            CoordinatorLayout.LayoutParams layoutParams =
                (CoordinatorLayout.LayoutParams)((View)contentView.Parent).LayoutParameters;

            CoordinatorLayout.Behavior behavior = layoutParams.Behavior;

            if (behavior != null)
            {
                var bttomCallback = new BottomSheetBehaviorOverride(SetOffsetText, SetStateText);

                ((BottomSheetBehavior)behavior).SetBottomSheetCallback(bttomCallback);
            }

            mOffsetText = contentView.FindViewById <TextView>(Resource.Id.offsetText);
            mStateText  = contentView.FindViewById <TextView>(Resource.Id.stateText);
        }