cascade icon indicating copy to clipboard operation
cascade copied to clipboard

Allow background dimming

Open saket opened this issue 3 years ago • 13 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.

saket avatar Oct 10 '20 06:10 saket

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.

gsrathoreniks avatar Oct 10 '20 18:10 gsrathoreniks

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

saket avatar Oct 10 '20 19:10 saket

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.

gsrathoreniks avatar Oct 11 '20 05:10 gsrathoreniks

//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

gsrathoreniks avatar Oct 11 '20 05:10 gsrathoreniks

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

saket avatar Oct 15 '20 01:10 saket

Let's give it a try!

gsrathoreniks avatar Oct 15 '20 05:10 gsrathoreniks

I was too late to view this thread 🤦.

rohithThammaiah avatar Oct 18 '20 15:10 rohithThammaiah

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?

https://user-images.githubusercontent.com/8607299/117559225-dcec8c80-b059-11eb-95b4-e76decca5891.mov

tucomel avatar May 09 '21 03:05 tucomel

Yep that should already be possible minus background dimming!

saket avatar May 11 '21 18:05 saket

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

fukemy avatar Jun 11 '22 03:06 fukemy

Screen

i cant see the video

fukemy avatar Oct 18 '23 17:10 fukemy

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

gsrathoreniks avatar Oct 18 '23 19:10 gsrathoreniks