Option to have arrow point at (center of) anchor view
See original GitHub issueIs your feature request related to a problem?
From what I can tell, by default the arrow of the balloon is rendered in the center of the balloon, and the balloon is center aligned with the anchor view when shown. This means that normally, the arrow points at the center of the anchor view. However, if there is not enough space to display the balloon this way (because the balloon reaches the edge of the screen), the balloon is automatically shifted, which also shifts the arrow, causing it to no longer point at the center of the anchor view. While it is possible to change where on the balloon the arrow is displayed by specifying a ratio other than the default 0.5, it is currently not possible to tell the balloon to render the arrow so that it always points at the anchor view. This results in the problem that, if the balloon is too big and the anchor view is small, the arrow does not point at the anchor view at all.
Describe the solution you’d like:
I would love to have an option to, instead of specifying a ratio of where the arrow should be, to specify that the arrow should point at the center of the anchor view (or optionally at a certain offset from the anchor view’s center).
Something like
enum class ArrowPositionMode {
ALIGN_WITH_BALLOON, // this will place the arrow in the center of the balloon, or shifted if setArrowPosition is used
ALIGN_WITH_ANCHOR // this will place the arrow in the center of the anchor view, or shifted if setArrowPosition is used
}
Balloon.Builder(context)
.setArrowPositionMode(ArrowPositionMode.ALIGN_WITH_ANCHOR)
Describe alternatives you’ve considered:
I tried to dynamically compute the arrow ratio when showing the balloon based on where the anchor view is, but for that I’d first have to create the balloon to measure its width, calculate what the arrow position should be, then destroy the balloon again and create a new one with the calculated arrow position (because the arrow position cannot be changed once the balloon is created).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:10 (6 by maintainers)
Top GitHub Comments
Cool. I tried
1.1.8-alpha02
and it seems to fix my issue 👍. ThanksThanks. I will try it out in my app once I have the time 👍