Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to have multiple gravity to the tooltip? #139

Open
tipialican opened this issue Aug 6, 2019 · 1 comment
Open

How to have multiple gravity to the tooltip? #139

tipialican opened this issue Aug 6, 2019 · 1 comment

Comments

@tipialican
Copy link

I am trying to place a tooltip to the bottom-right of a view, which happens to be at the right most side of the screen.
However, not using fitToScreen ends up with tooltip being outside of the screen, where an xOffset needs to be set, however this offset is not very reliable since the text can change in the tooltip.
Using fitToScreen also ends up creating a problem where tooltip automatically is set to Gravity.LEFT since bottom is not an option ( because it tries to draw it outside of the screen )

Here is a piece of code:

 val width = resources.displayMetrics.widthPixels * 2  / 3
        val tooltipPaddingRight = resources.getDimensionPixelSize(R.dimen.tooltip_margin_right)
        val tooltip = Tooltip.Builder(requireContext())
                .anchor(imageViewAction,-width / 2 + tooltipPaddingRight,0, false)
                .text("Tooltip message here")
                .maxWidth(width)
                .arrow(false)
                .styleId(R.style.SomeStyle)
                .showDuration(3000)
                .closePolicy(ClosePolicy.TOUCH_ANYWHERE_NO_CONSUME)
                .overlay(false)
                .create()

        tooltip.show(plusButton, Tooltip.Gravity.BOTTOM,true)
@Dagzo
Copy link

Dagzo commented Dec 13, 2019

@tipialican
Hello, I have 2 ideas. I hope this will help.

  1. Set gravity as Tooltip.Gravity.RIGHT then add Y offset like .anchor(imageViewAction,0,48, false).
  2. Make invisible view under plusButton then set it as anchor and set gravity as Tooltip.Gravity.RIGHT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants