private Android.Widget.Button GetButton(ToolbarItem item)
        {
            var button = new Android.Widget.Button(_rightMenuLayout.Context)
            {
                Text = item.Text
            };

            button.Click += (object sender, System.EventArgs e) => {
                item.Activate();
            };
            //button.SetTextColor(Element.BarTextColor.ToAndroid());
            button.SetTextColor(Android.Graphics.Color.Red);
            button.SetBackgroundColor(Android.Graphics.Color.Transparent);
            button.SetMinWidth(10);
            button.SetMinimumWidth(10);
            button.SetPadding(5, 0, 5, 0);
            button.LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);
            return(button);
        }
Ejemplo n.º 2
0
        protected override void OnElementChanged(ElementChangedEventArgs <Stepper> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                _downButton = new Android.Widget.Button(Context)
                {
                    Text = "-", Gravity = GravityFlags.Center, Tag = this
                };
                //Set the MinWidth of Button
                _downButton.SetMinWidth(50);

                _downButton.SetOnClickListener(StepperListener.Instance);

                _upButton = new Android.Widget.Button(Context)
                {
                    Text = "+", Tag = this
                };
                _upButton.SetOnClickListener(StepperListener.Instance);
                //Set the MinWidth of Button
                _upButton.SetMinWidth(50);

                if (e.NewElement != null)
                {
                    //Set the Width and Height of the button according to the WidthRequest
                    _downButton.LayoutParameters = new LayoutParams((int)e.NewElement.WidthRequest, LayoutParams.MatchParent);
                    _upButton.LayoutParameters   = new LayoutParams((int)e.NewElement.WidthRequest, LayoutParams.MatchParent);
                }

                var layout = CreateNativeControl();

                layout.AddView(_downButton);
                layout.AddView(_upButton);

                SetNativeControl(layout);
            }

            UpdateButtonEnabled();
        }