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

Shadow not displaying. SetElevation not working #35

Closed
GuillemRoca opened this issue Apr 2, 2020 · 7 comments
Closed

Shadow not displaying. SetElevation not working #35

GuillemRoca opened this issue Apr 2, 2020 · 7 comments
Assignees
Labels
Released Released already on the latest version.

Comments

@GuillemRoca
Copy link
Contributor

GuillemRoca commented Apr 2, 2020

Please complete the following information:

  • Library-Version [v1.1.4]
  • Affected Device(s) [Android Emulator Pixel 3a with Android 9.0 API 28 - Google Play]
  • Min API [21]

Describe the Bug:

I tried the parameter setElevation in order to display the shadow as recently you released this feature in version 1.1.3 and I couldn't manage to get it to work.

I've tested in my own app and in the sample of the repo and I couldn't manage to get it to work, I've edited all the Factories without success:

Sample code

class TagBalloonFactory : Balloon.Factory() {

  override fun create(context: Context, lifecycle: LifecycleOwner?): Balloon {
    return createBalloon(context) {
      setLayout(R.layout.layout_custom_tag)
      setArrowSize(10)
      setArrowOrientation(ArrowOrientation.BOTTOM)
      setArrowPosition(0.5f)
      setElevation(10f)
      setPadding(4)
      isRtlSupport(BalloonUtils.isRtlLayout())
      setCornerRadius(4f)
      setBalloonAnimationStyle(R.style.ElasticAndFadeOut)
      setBackgroundColorResource(R.color.white_93)
      setAutoDismissDuration(2000L)
      setDismissWhenClicked(true)
      setDismissWhenShowAgain(true)
      setLifecycleOwner(lifecycle)
    }
  }
}

Also shouldn't the elevation be set as the padding or the width/height which is an Int and not a Float for consistency API reasons? The elevation should also be applied in dp.

Expected Behavior:

The elevation should behave as normal and be displayed in the UI.

PS: Thanks for the awesome library! Keep up the good work! 💪

@rajal2009
Copy link

Yes, I am also using setElevation and setArrowColor but not working.

it's just display normal background without elevation and arrow color can not be changed

@skydoves
Copy link
Owner

skydoves commented Apr 2, 2020

@GuillemRoca @rajal2009
Hi, I checked this issue just now and I will try to fix it soon!
If you have any idea, please let me know or make a pull request! Thank you for your issue :)

@skydoves
Copy link
Owner

skydoves commented Apr 2, 2020

@rajal2009
Also, I checked the setArrowColor method is not working when the color is white.
It will be fixed on the next release! Thank you for your issue :)

@GuillemRoca
Copy link
Contributor Author

Hello @skydoves!

After a brief investigation, I believe this could be caused by this.

In the method:

  private fun initializeBalloonListeners() {
    this.onBalloonClickListener = builder.onBalloonClickListener
    this.onBalloonDismissListener = builder.onBalloonDismissListener
    this.onBalloonOutsideTouchListener = builder.onBalloonOutsideTouchListener
    this.bodyView.setOnClickListener {
      this.onBalloonClickListener?.onBalloonClick(it)
      if (builder.dismissWhenClicked) dismiss()
    }
    with(this.bodyWindow) {
      setOnDismissListener { onBalloonDismissListener?.onBalloonDismiss() }
      setBackgroundDrawable(ColorDrawable(Color.WHITE))
      isOutsideTouchable = true
      setTouchInterceptor(object : View.OnTouchListener {
        @SuppressLint("ClickableViewAccessibility")
        override fun onTouch(view: View, event: MotionEvent): Boolean {
          if (event.action == MotionEvent.ACTION_OUTSIDE) {
            if (builder.dismissWhenTouchOutside) {
              this@Balloon.dismiss()
            }
            onBalloonOutsideTouchListener?.onBalloonOutsideTouch(view, event)
            return true
          }
          return false
        }
      })
    }
  }


I've changed the setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) to White and now the elevation is displayed correctly! 🍾

The bad thing is that it messes with the arrow and the background set in the API. Maybe you can help me get to the final solution.

@skydoves skydoves added this to the 1.1.5 milestone Apr 4, 2020
@skydoves skydoves removed this from the 1.1.5 milestone Apr 26, 2020
@skydoves skydoves added enhancement New feature or request Release Next This feature will be released on next version Released Released already on the latest version. and removed enhancement New feature or request labels May 12, 2020
@skydoves
Copy link
Owner

Hi, @GuillemRoca , @rajal2009
It is fixed on version 1.1.7.
Thank you for your issue! :)

@skydoves skydoves removed the Release Next This feature will be released on next version label May 17, 2020
@GuillemRoca
Copy link
Contributor Author

Awesome! I will take a look and test it! 😄

@GuillemRoca
Copy link
Contributor Author

I've finally had time to test it and it works as intended! Great work and great library! :D

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

No branches or pull requests

3 participants