예제 #1
0
        void CreateToolbar()
        {
            _toolbar    = new Toolbar(this);
            _toolbar.Id = Resource.Id.toolbar;
            ConstraintLayout.LayoutParams clptoolbar = new ConstraintLayout.LayoutParams(
                ConstraintLayout.LayoutParams.MatchParent, ConstraintLayout.LayoutParams.WrapContent);
            _toolbar.LayoutParameters = clptoolbar;
            //_toolbar.Title = "OCBB";
            _toolbar.SetTitleTextColor(Color.White);
            _toolbar.SetBackgroundColor(Color.ParseColor("#00bbcc"));
            _toolbar.SetSubtitleTextColor(Color.ParseColor("#ffffff"));
            _toolbar.SetSubtitleTextAppearance(this, Resource.Style.TextAppearance_Widget_AppCompat_Toolbar_Subtitle);

            BaseScrollView.RemoveView(BaseElementsConstraintLayout);
            BaseMainConstraintLayout.RemoveView(BaseScrollView);
            BaseMainConstraintLayout.RemoveView(BasePreLoaderConstraintLayout);
            BasePreLoaderConstraintLayout.RemoveView(BaseProgressBar);

            BaseElementsConstraintLayout.AddView(_toolbar);
            BaseMainConstraintLayout.AddView(BaseElementsConstraintLayout);

            BaseMainConstraintLayout.AddView(BasePreLoaderConstraintLayout);
            BasePreLoaderConstraintLayout.AddView(BaseProgressBar);
            CreateMainConstraintSet();
        }
        private void InitLayout()
        {
            _constraintLayoutRoot = this.BindingInflate(LayoutId, null) as ConstraintLayout;

            ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MatchConstraint, ConstraintLayout.LayoutParams.MatchConstraint);
            _constraintLayoutRoot.LayoutParameters = layoutParams;

            BaseMainConstraintLayout.RemoveView(BaseScrollView);
            BaseScrollView.RemoveView(BaseElementsConstraintLayout);
            BaseMainConstraintLayout.AddView(BaseElementsConstraintLayout);

            BaseMainConstraintLayout.BringChildToFront(BasePreLoaderConstraintLayout);

            var rootElementSet = new ConstraintSet();

            rootElementSet.Clone(BaseMainConstraintLayout);
            rootElementSet.Connect(BaseElementsConstraintLayout.Id, ConstraintSet.Top, BaseMainConstraintLayout.Id, ConstraintSet.Top);
            rootElementSet.Connect(BaseElementsConstraintLayout.Id, ConstraintSet.Bottom, BaseMainConstraintLayout.Id, ConstraintSet.Bottom);
            rootElementSet.Connect(BaseElementsConstraintLayout.Id, ConstraintSet.Left, BaseMainConstraintLayout.Id, ConstraintSet.Left);
            rootElementSet.Connect(BaseElementsConstraintLayout.Id, ConstraintSet.Right, BaseMainConstraintLayout.Id, ConstraintSet.Right);
            rootElementSet.ApplyTo(BaseMainConstraintLayout);

            BaseElementsConstraintLayout.AddView(_constraintLayoutRoot);

            ConstraintSet elementsSet = new ConstraintSet();

            elementsSet.Clone(BaseElementsConstraintLayout);

            elementsSet.Connect(_constraintLayoutRoot.Id, ConstraintSet.Top, _toolbar.Id, ConstraintSet.Bottom);
            elementsSet.Connect(_constraintLayoutRoot.Id, ConstraintSet.Bottom, BaseElementsConstraintLayout.Id, ConstraintSet.Bottom);
            elementsSet.Connect(_constraintLayoutRoot.Id, ConstraintSet.Left, BaseElementsConstraintLayout.Id, ConstraintSet.Left);
            elementsSet.Connect(_constraintLayoutRoot.Id, ConstraintSet.Right, BaseElementsConstraintLayout.Id, ConstraintSet.Right);

            elementsSet.ApplyTo(BaseElementsConstraintLayout);
        }