Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        List <Listdata> _data = new List <Listdata>();

        _data.Add(new Listdata("0"));
        _data.Add(new Listdata("1"));
        _data.Add(new Listdata("2"));
        _data.Add(new Listdata("3"));
        _data.Add(new Listdata("4"));
        _data.Add(new Listdata("5"));
        _data.Add(new Listdata("6"));
        _data.Add(new Listdata("7"));
        _data.Add(new Listdata("8"));
        _data.Add(new Listdata("9"));
        _data.Add(new Listdata("10"));
        _data.Add(new Listdata("11"));
        _data.Add(new Listdata("12"));
        _data.Add(new Listdata("13"));
        _data.Add(new Listdata("00"));
        _data.Add(new Listdata("01"));
        _data.Add(new Listdata("02"));
        _data.Add(new Listdata("03"));
        _data.Add(new Listdata("04"));
        _data.Add(new Listdata("05"));
        _data.Add(new Listdata("06"));
        _data.Add(new Listdata("07"));
        _data.Add(new Listdata("08"));
        _data.Add(new Listdata("09"));
        _data.Add(new Listdata("010"));
        _data.Add(new Listdata("011"));
        _data.Add(new Listdata("012"));
        _data.Add(new Listdata("013"));
        GameObject m_BaseScrollViewPrefab = Instantiate <GameObject>(_BaseScrollViewPrefab);

        m_BaseScrollViewPrefab.transform.SetParent(transform);
        m_BaseScrollViewPrefab.transform.localPosition = Vector3.zero;
        BaseScrollView _BaseScrollView = m_BaseScrollViewPrefab.GetComponent <BaseScrollView>();

        _BaseScrollView.objectsDataArr = new ArrayList(_data);
        _BaseScrollView.RefreshPrefabs(_data);
    }
        public static void Show(string text, BaseScrollView view = null
                                )
        {
#if __ANDROID__
            if (toast != null)
            {
                toast.Cancel();
            }

            toast = Android.Widget.Toast.MakeText(Xamarin.Forms.Forms.Context, text, Android.Widget.ToastLength.Short);
            toast.Show();
#elif __IOS__
            ToastIOS.Toast.MakeText(text).SetFontSize(12f).Show();
#elif __UWP__
            if (view != null)
            {
                view.Toast(text);
            }
            else
            {
                new Windows.UI.Popups.MessageDialog(text);
            }
#endif
        }
Ejemplo n.º 5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "DynamicHeightObserverView";
            InitializeScrollView();

            var headerLabel = new UILabel()
            {
                Text = "Wait 3 seconds...", TextAlignment = UITextAlignment.Center
            };
            var blueView = new UIView()
            {
                BackgroundColor = UIColor.Blue
            };

            _tableView = new UITableView()
            {
                ScrollEnabled = false
            };
            _tableView.RowHeight          = UITableView.AutomaticDimension;
            _tableView.EstimatedRowHeight = 30;
            _tableView.TableFooterView    = new UIView();
            var source = new MvxSimpleTableViewSource(_tableView, typeof(ItemCell), ItemCell.Key);

            _tableView.Source = source;

            var greenView = new UIView()
            {
                BackgroundColor = UIColor.Green
            };
            var footerLabel = new UILabel()
            {
                Text = "Footer", TextAlignment = UITextAlignment.Center
            };

            var bindingSet = this.CreateBindingSet <DynamicHeightObserverView, DynamicHeightObserverViewModel>();

            bindingSet.Bind(source).To(vm => vm.Items);
            bindingSet.Apply();

            _tableView.ReloadData();
            _tableViewHeightFluentLayout = _tableView.Height().EqualTo(0);

            BaseContentView.AddSubviews(headerLabel, blueView, _tableView, greenView, footerLabel);
            BaseScrollView.AddSubviews(BaseContentView);
            View.AddSubviews(BaseScrollView);

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            View.AddConstraints(
                BaseScrollView.AtTopOf(View),
                BaseScrollView.AtLeftOf(View),
                BaseScrollView.AtRightOf(View),
                BaseScrollView.AtBottomOf(View),

                BaseContentView.WithSameWidth(View)
                );

            BaseScrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            BaseScrollView.AddConstraints(
                BaseContentView.Bottom().EqualTo().BottomOf(BaseScrollView),
                BaseContentView.AtTopOf(BaseScrollView)
                );

            BaseContentView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            BaseContentView.AddConstraints(
                headerLabel.AtTopOf(BaseContentView, 8),
                headerLabel.AtLeftOf(BaseContentView, 8),
                headerLabel.AtRightOf(BaseContentView, 8),

                blueView.Below(headerLabel, 8),
                blueView.WithSameLeft(headerLabel),
                blueView.WithSameRight(headerLabel),
                blueView.Height().EqualTo(50),

                _tableView.Below(blueView, 8),
                _tableView.WithSameLeft(headerLabel),
                _tableView.WithSameRight(headerLabel),
                _tableViewHeightFluentLayout,

                greenView.Below(_tableView, 8),
                greenView.WithSameLeft(headerLabel),
                greenView.WithSameRight(headerLabel),
                greenView.WithSameHeight(blueView),

                footerLabel.Below(greenView, 8),
                footerLabel.WithSameLeft(headerLabel),
                footerLabel.WithSameRight(headerLabel),
                footerLabel.AtBottomOf(BaseContentView, 8)
                );
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 初始化item属性
 /// </summary>
 /// <param name="index">索引</param>
 /// <param name="view">管理对象</param>
 public void InitViewItem(int index, BaseScrollView view)
 {
     ViewItemIndex   = index;
     _baseScrollView = view;
 }