Пример #1
0
        public override void OnViewAdded(Android.Views.View child)
        {
            base.OnViewAdded(child);

            if (child.GetType() == typeof(Support.Toolbar))
            {
                var lastPage = Element?.Navigation?.NavigationStack?.Last();

                /*if (_toolbar !=null)
                 * {
                 *  _toolbar.ChildViewAdded -= OnToolbarChildViewAdded;
                 *  var lPage = Element?.Navigation?.NavigationStack?.Last();
                 *  lPage.PropertyChanged -= LastPage_PropertyChanged;
                 * }*/

                _toolbar = (Android.Support.V7.Widget.Toolbar)child;
                _originalToolbarBackground = _toolbar.Background;

                var originalContent = (Context as Activity)?.Window?.DecorView?.FindViewById <FrameLayout>(Window.IdAndroidContent);
                if (originalContent != null)
                {
                    _originalWindowContent = originalContent.Foreground;
                }

                _parentLayout = new Android.Widget.FrameLayout(_toolbar.Context)
                {
                    LayoutParameters = new Android.Widget.FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)
                };

                //Create custom title view layout
                _titleViewLayout = new Android.Widget.LinearLayout(_parentLayout.Context)
                {
                    Orientation      = Android.Widget.Orientation.Vertical,
                    LayoutParameters = new Android.Widget.FrameLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent)
                };

                _titleTextView = new AppCompatTextView(_parentLayout.Context)
                {
                    LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent)
                };

                //Add title/subtitle to title view layout
                _titleViewLayout.AddView(_titleTextView);


                //Add title view layout to main layout
                _parentLayout.AddView(_titleViewLayout);

                //Add main layout to toolbar
                _toolbar.AddView(_parentLayout);

                _toolbar.ChildViewAdded += OnToolbarChildViewAdded;

                lastPage.PropertyChanged += LastPage_PropertyChanged;
            }
        }
Пример #2
0
 private IEnumerable <AV.View> GetChildrenViews()
 {
     foreach (var v in this.Element.Children)
     {
         var render = RendererFactory.GetRenderer(v);
         var c      = new AW.FrameLayout(this.Context);
         c.SetBackgroundColor(Color.Blue.ToAndroid());
         c.AddView(render.ViewGroup, LayoutParams.MatchParent, LayoutParams.MatchParent);
         yield return(c);
     }
 }
        void CreateDialog()
        {
            _picker          = new APicker(_context);
            _picker.MinValue = _min;
            _picker.MaxValue = _max;
            if (_NumberPickerCell.Number.HasValue)
            {
                _picker.Value = _NumberPickerCell.Number.Value;
            }

            if (!String.IsNullOrEmpty(_NumberPickerCell.Unit))
            {
                _picker.SetFormatter(new UnitFormatter(_NumberPickerCell.Unit));
                ApplyInitialFormattingBugfix(_picker);
            }

            if (_dialog == null)
            {
                using (var builder = new AlertDialog.Builder(_context)) {
                    builder.SetTitle(_title);

                    Android.Widget.FrameLayout parent = new Android.Widget.FrameLayout(_context);
                    parent.AddView(_picker, new Android.Widget.FrameLayout.LayoutParams(
                                       ViewGroup.LayoutParams.WrapContent,
                                       ViewGroup.LayoutParams.WrapContent,
                                       GravityFlags.Center));
                    builder.SetView(parent);


                    builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) =>
                    {
                        ClearFocus();
                    });
                    builder.SetPositiveButton(global::Android.Resource.String.Ok, (o, args) =>
                    {
                        _NumberPickerCell.Number = _picker.Value;
                        _command?.Execute(_picker.Value);
                        ClearFocus();
                    });

                    _dialog = builder.Create();
                }
                _dialog.SetCanceledOnTouchOutside(true);
                _dialog.DismissEvent += (ss, ee) =>
                {
                    DestroyDialog();
                };

                _dialog.Show();
            }
        }
Пример #4
0
        private void SetItems(int width, int height)
        {
            this.Container.RemoveAllViewsInLayout();
            //Form 中的大小转换到 Android 下, 要跟据 密度(Density) 转换, 最终结果可能并不是 Form 中指定的
            //var density = this.Context.Resources.DisplayMetrics.Density;
            //var w = this.Element.WidthRequest * density;
            //var h = this.Element.HeightRequest * density;

            foreach (var v in this.Element.Children)
            {
                var render = RendererFactory.GetRenderer(v);

                var c = new Android.Widget.FrameLayout(this.Context);
                c.SetBackgroundColor(Color.Blue.ToAndroid());
                c.AddView(render.ViewGroup);
                this.Container.AddView(c, width, height);
            }
            this.Count = this.Element.Children.Count();
        }
Пример #5
0
 private IEnumerable <AV.View> GetChildrenViews()
 {
     if (this.Element != null)
     {
         foreach (var v in this.Element.Children)
         {
             //var render = RendererFactory.GetRenderer(v);
             var render = v.GetOrCreateRenderer(); //Platform.CreateRenderer(v);
             if (render.ViewGroup.Parent == null)
             {
                 var c = new AW.FrameLayout(this.Context);
                 //c.SetBackgroundColor(Color.Blue.ToAndroid());
                 c.AddView(render.ViewGroup, LayoutParams.MatchParent, LayoutParams.MatchParent);
                 yield return(c);
             }
             else
             {
                 yield return((AV.View)render.ViewGroup.Parent);
             }
         }
     }
 }