In one of my project I used PopupWindow. My problem is while viewing popupwindow the design seems to be uncomfortable to work. So I want to dim or blur my activity background. I searched a lot, but most of the answers seems only for Dialog not for PopupWindow. Is it possible in android to dim our activity background while viewing PopupWindaow. 
            Asked
            
        
        
            Active
            
        
            Viewed 1.4k times
        
    2
            
            
        
        Cœur
        
- 37,241
 - 25
 - 195
 - 267
 
        Gunaseelan
        
- 14,415
 - 11
 - 80
 - 128
 
- 
                    why not use a Dialog if it provides dimming the background? – Axarydax Mar 26 '13 at 06:43
 - 
                    No friend. I have completed my project. If it is not possible means then only way to move `Dialog`. Now only I am searching friend. – Gunaseelan Mar 26 '13 at 06:48
 - 
                    1See this related question: http://stackoverflow.com/questions/3221488/blur-or-dim-background-when-android-popupwindow-active – Axarydax Mar 26 '13 at 06:50
 
5 Answers
6
            I solved this problem by setting the background to the layout of the pop-up window with the following.
android:background="#80FFFFFF"
Thnaks..And it works as expected.
        Born To Win
        
- 3,319
 - 3
 - 19
 - 27
 
3
            
            
        you can simply use this :
ColorDrawable dw = new ColorDrawable(0xb0000000);
dialog.getWindow().setBackgroundDrawable(dw);
        SyraKozZ
        
- 607
 - 8
 - 17
 
- 
                    I wasn't clear on what 'this' is.. but it got me on the right track -thanks! For a dialog popup, this worked: dialog.getWindow().setBackgroundDrawable(dw); – Gene Bo Mar 10 '15 at 19:45
 
1
            
            
        There is always a work around. Before showing your PopupWindow use another PopupWindow which has nothing but a dark translucent tint. Also when dismissing dismiss both pop up windows in the reverse sequence.
For code see this
        Community
        
- 1
 - 1
 
        Abhishek Nandi
        
- 4,265
 - 1
 - 30
 - 43
 
-1
            
            
        Yes, it is possible, try android:theme="@android:style/Theme.Translucent" , it will make your activity transparent.
        Raynold
        
- 443
 - 2
 - 9
 - 28
 
- 
                    while viewing my `PopupWindaow` only I want it to dim friend. After closing `PopupWindaow`I want to cancel that dim. – Gunaseelan Mar 26 '13 at 06:45
 
-1
            
            
        Try this
 Window window = popUpView.getWindow();
    WindowManager.LayoutParams wlp = window.getAttributes();
    wlp.gravity = Gravity.CENTER_VERTICAL;
    wlp.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    wlp.dimAmount = (float) 1.0;
    window.setAttributes(wlp);
        Devu Soman
        
- 2,246
 - 13
 - 36
 - 57