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.75k stars 291 forks source link

Tooltips don't disappear when leaving fragment #29

Closed ivnsch closed 4 years ago

ivnsch commented 4 years ago

Please complete the following information:

Describe the Bug:

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)

When I leave the fragment (e.g. to navigate to a new fragment). The tooltips stay on the screen.

Expected Behavior:

The tooltips disappear when navigating away (backwards or forwards) from fragment.

skydoves commented 4 years ago

Unfortunately, the balloon popup is not a view. It is a popup window. So the window can't be related to fragments back stacks or viewpager.

ivnsch commented 4 years ago

Okay, I'd store the tooltips in a variable and close them manually when leaving the fragment.

ivnsch commented 4 years ago

@skydoves is there a way to dismiss the tooltip without animating it? The close animation makes the tooltip stay a while on the screen while navigating away, which looks weird.

skydoves commented 4 years ago

@i-schuetz You can write customized animation styles. Add below codes in your styles.xml.

<style name="BalloonDispose">
  <item name="android:windowEnterAnimation">@anim/elastic_center</item>
  <item name="android:windowExitAnimation">@null</item>
</style>

There are seven types of default customized styles.

Remove setBalloonAnimation method and use setBalloonAnimationStyle(R.style.BalloonDispose) method. Thanks.

ivnsch commented 4 years ago

The problem is that I want to disable the animation only when dismissing as part of leaving the screen. I want to keep them for normal usage.