Exemplo n.º 1
0
        public void OnClick(View view)
        {
            String text = TextUtils.IsEmpty(_editText.Text) ? _tip_text : _editText.Text;

            ToolTip.Builder builder;

            switch (view.Id)
            {
            case Resource.Id.button_above:
                _toolTipsManager.FindAndDismiss(_textView);
                builder = new ToolTip.Builder(this, _textView, _rootLayout, text, ToolTip.PositionAbove);
                builder.SetAlign(_align);
                _toolTipsManager.Show(builder.Build());
                break;

            case Resource.Id.button_below:
                _toolTipsManager.FindAndDismiss(_textView);
                builder = new ToolTip.Builder(this, _textView, _rootLayout, text, ToolTip.PositionBelow);
                builder.SetAlign(_align);
                builder.SetBackgroundColor(ContextCompat.GetColor(this, Resource.Color.colorOrange));
                _toolTipsManager.Show(builder.Build());
                break;

            case Resource.Id.button_left_to:
                _toolTipsManager.FindAndDismiss(_textView);
                builder = new ToolTip.Builder(this, _textView, _rootLayout, text, ToolTip.PositionLeftTo);
                builder.SetBackgroundColor(ContextCompat.GetColor(this, Resource.Color.colorLightGreen));
                builder.SetTextColor(ContextCompat.GetColor(this, Resource.Color.colorBlack));
                builder.SetGravity(ToolTip.GravityCenter);
                builder.SetTextSize(12);
                _toolTipsManager.Show(builder.Build());
                break;

            case Resource.Id.button_right_to:
                _toolTipsManager.FindAndDismiss(_textView);
                builder = new ToolTip.Builder(this, _textView, _rootLayout, text, ToolTip.PositionRightTo);
                builder.SetBackgroundColor(ContextCompat.GetColor(this, Resource.Color.colorDarkRed));
                builder.SetTextColor(ContextCompat.GetColor(this, Resource.Color.colorWhite));
                _toolTipsManager.Show(builder.Build());
                break;

            case Resource.Id.button_align_center:
                _align = ToolTip.AlignCenter;
                break;

            case Resource.Id.button_align_left:
                _align = ToolTip.AlignLeft;
                break;

            case Resource.Id.button_align_right:
                _align = ToolTip.AlignRight;
                break;
            }
        }
Exemplo n.º 2
0
        public void ShowTooltip(Xamarin.Forms.View onView, TooltipConfig config)
        {
            var control = GetOrCreateRenderer(onView).View;

            if (!string.IsNullOrEmpty(config.Text))
            {
                ToolTip.Builder builder;
                var             position      = config.Position;
                var             parentContent = control.RootView;
                switch (position)
                {
                case TooltipPosition.Top:
                    builder = new ToolTip.Builder(global::Android.App.Application.Context, control,
                                                  parentContent as ViewGroup, config.Text.PadRight(80, ' '), ToolTip.PositionAbove);
                    break;

                case TooltipPosition.Left:
                    builder = new ToolTip.Builder(global::Android.App.Application.Context, control,
                                                  parentContent as ViewGroup, config.Text.PadRight(80, ' '), ToolTip.PositionLeftTo);
                    break;

                case TooltipPosition.Right:
                    builder = new ToolTip.Builder(global::Android.App.Application.Context, control,
                                                  parentContent as ViewGroup, config.Text.PadRight(80, ' '), ToolTip.PositionRightTo);
                    break;

                default:
                    builder = new ToolTip.Builder(global::Android.App.Application.Context, control,
                                                  parentContent as ViewGroup, config.Text.PadRight(80, ' '), ToolTip.PositionBelow);
                    break;
                }

                builder.SetAlign(ToolTip.AlignLeft);
                builder.SetBackgroundColor(config.BackgroundColor.ToAndroid());
                builder.SetTextColor(config.TextColor.ToAndroid());

                toolTipView = builder.Build();

                _toolTipsManager?.Show(toolTipView);
            }
        }
Exemplo n.º 3
0
        protected override void OnAttached()
        {
            var control = Control ?? Container;

            listener.command = TooltipEffect.GetDismishedCommand(Element);
            var text = TooltipEffect.GetText(Element);

            if (!string.IsNullOrEmpty(text))
            {
                ToolTip.Builder builder;
                var             parentContent = control.RootView;
                var             position      = TooltipEffect.GetPosition(Element);
                switch (position)
                {
                case TooltipPosition.Top:
                    builder = new ToolTip.Builder(control.Context, control, parentContent as ViewGroup, text.PadRight(80, ' '), ToolTip.PositionAbove);
                    break;

                case TooltipPosition.Left:
                    builder = new ToolTip.Builder(control.Context, control, parentContent as ViewGroup, text.PadRight(80, ' '), ToolTip.PositionLeftTo);
                    break;

                case TooltipPosition.Right:
                    builder = new ToolTip.Builder(control.Context, control, parentContent as ViewGroup, text.PadRight(80, ' '), ToolTip.PositionRightTo);
                    break;

                default:
                    builder = new ToolTip.Builder(control.Context, control, parentContent as ViewGroup, text.PadRight(80, ' '), ToolTip.PositionBelow);
                    break;
                }

                builder.SetAlign(ToolTip.AlignLeft);
                builder.SetBackgroundColor(TooltipEffect.GetBackgroundColor(Element).ToAndroid());
                builder.SetTextColor(TooltipEffect.GetTextColor(Element).ToAndroid());

                toolTipView = builder.Build();
                builder.Dispose();
                _toolTipsManager?.Show(toolTipView);
                listener.toolTipsManager = _toolTipsManager;
            }
        }
        void OnTap(object sender, EventArgs e)
        {
            var control = Control ?? Container;

            var text = TooltipEffect.GetText(Element);

            if (!string.IsNullOrEmpty(text))
            {
                ToolTip.Builder builder;
                var             parentContent = control.RootView;

                var position = TooltipEffect.GetPosition(Element);
                switch (position)
                {
                case TooltipPosition.Top:
                    builder = new ToolTip.Builder(control.Context, control, parentContent as ViewGroup, text.PadRight(80, ' '), ToolTip.PositionAbove);
                    break;

                case TooltipPosition.Left:
                    builder = new ToolTip.Builder(control.Context, control, parentContent as ViewGroup, text.PadRight(80, ' '), ToolTip.PositionLeftTo);
                    break;

                case TooltipPosition.Right:
                    builder = new ToolTip.Builder(control.Context, control, parentContent as ViewGroup, text.PadRight(80, ' '), ToolTip.PositionRightTo);
                    break;

                default:
                    builder = new ToolTip.Builder(control.Context, control, parentContent as ViewGroup, text.PadRight(80, ' '), ToolTip.PositionBelow);
                    break;
                }

                builder.SetAlign(ToolTip.AlignLeft);
                builder.SetBackgroundColor(TooltipEffect.GetBackgroundColor(Element).ToAndroid());
                builder.SetTextColor(TooltipEffect.GetTextColor(Element).ToAndroid());

                toolTipView = builder.Build();

                _toolTipsManager?.Show(toolTipView);
            }
        }