skydoves / Balloon

:balloon: Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android.
https://skydoves.github.io/libraries/balloon/html/balloon/com.skydoves.balloon/index.html
Apache License 2.0
3.73k stars 291 forks source link

Tooltip not centered #28

Closed ivnsch closed 4 years ago

ivnsch commented 4 years ago

Please complete the following information:

Describe the Bug:

packageEdit.setOnClickListener {
    packageTitle.showBalloon(this)
}

packageTitle is the label where it should appear centered. Settings:

setArrowSize(10)
//        setWidthRatio(1.0f)
setHeight(65)
setPadding(0)
setDismissWhenTouchOutside(true)
setPaddingLeft(10)
setPaddingRight(10)
//        setArrowPosition(.5f)
setSpace(10)
setCornerRadius(10f)
setAlpha(1f)
setTextColorResource(R.color.white)
setBackgroundColorResource(R.color.colorAccent)
setOnBalloonClickListener {
    onClick?.invoke()
}
setBalloonAnimation(BalloonAnimation.ELASTIC)
setLifecycleOwner(lifecycleOwner)

Happens when using in RecyclerView. Position seems to be random, on other cells it appears at different non-centered positions. I haven't tested without RecyclerView.

Screen Shot 2020-03-24 at 15 53 33

Expected Behavior:

The tooltip appears centered horizontally over the text label.

skydoves commented 4 years ago

31

skydoves commented 4 years ago

The measuring isn't always correct because of Android SDK's view hierarchy problem. So you should make a clear position using x-off and y-off when showing a balloon.

ivnsch commented 4 years ago

Which problem exactly? I could write code to measure the label's width and set x-off accordingly, but it doesn't seem something that the library can't do directly?

skydoves commented 4 years ago

@i-schuetz Hi, I found the problem, it will be fixed in the next version. :) Thank you for your issue!

ivnsch commented 4 years ago

@skydoves Awesome, thank you! Would this be 1.1.3?

skydoves commented 4 years ago

It will be released on 1.1.4 today. Thank you :)

skydoves commented 4 years ago

@i-schuetz Hi, it is released a new version 1.1.4. You can check now!

ivnsch commented 4 years ago

It's working now, thanks!