saket / cascade

Nested popup menus with smooth height animations for Android

Home Page:https://saket.github.io/cascade

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow background dimming

saket opened this issue · comments

PopupWindow allows dimming background, but it's a bit difficult do so and doesn't animate in sync with entry/exist transitions. Providing a first-class API for doing it would be sweet.

This can be achieved on the implementation side by using a "View" and changing alpha from 0F to 1.5F(acc. to the intensity required) but this might not be a good idea but could be a way-around.

Using a View would require touching the view hierarchy of the background window. It may not be a very bad idea, but I'd like to know if it can avoided by only using PopupWindow's APIs

Using a View would require touching the view hierarchy of the background window. It may not be a very bad idea, but I'd like to know if it can avoided by only using PopupWindow's APIs

I'm some what succeeded in setting the background dim but clearing background is not yet done, If you can have a look at it once.

//function to apply the backgroundDim
  fun applyDim(parent: ViewGroup, dimAmount: Int) {
    val dim: Drawable = ColorDrawable(BLACK)
    dim.setBounds(0, 0, parent.width, parent.height)
    dim.alpha = dimAmount
    val overlay = parent.overlay
    overlay.add(dim)
  }

//function to clear the backgroundDim
  fun clearDim(parent: ViewGroup) {
    val overlay = parent.overlay
    overlay.clear()
  }

Used this

Yeah sure I wouldn't mind doing that. Wanna take a stab?

Let's give it a try!

I was too late to view this thread 🤦.

could this lib be used to achiev telegram action popup with background dim like video below? or It only can be used on toolbar actionbutton?

take.2021-05-09.at.00.01.55.mov

Yep that should already be possible minus background dimming!

commented

Hi, can we using blur view like ios (Context menu)? It's think it's better when support more customView like this:
165982759-5a5d6eb2-592c-4568-88c0-719d23012d6b

Screen_recording_20231018_180308.webm

Able to do it.

commented

Screen

i cant see the video

@fukemy I've added support for background dimming. Blur is not yet supported.