0

When the popupwindow is active, I want to make the screen into dimmer or blur expect selected view. Same like below mentioned image. enter image description here

I have tried the below code but its dimming entire screen

public static void dimBehind(PopupWindow popupWindow) {
       View container = popupWindow.getContentView().getRootView();
       Context context = popupWindow.getContentView().getContext();
       WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
       WindowManager.LayoutParams p = (WindowManager.LayoutParams) container.getLayoutParams();
       p.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
       p.screenBrightness=
       p.dimAmount = 0.3f;
       wm.updateViewLayout(container, p);
   }

below code is for popup window

public void showpopupwindow(View view){
       LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
       View customView = layoutInflater.inflate(R.layout.popup,null);



       //instantiate popup window
       PopupWindow  popupWindow = new PopupWindow(mContext);
       popupWindow.setContentView(customView);
       popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
       popupWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
       popupWindow.setFocusable(true);

       //display the popup window
       popupWindow.showAsDropDown(view);
       dimBehind(popupWindow);


       TextView textView1,textView2,textView3,textView4;
       textView1=customView.findViewById(R.id.textview1);
       textView2=customView.findViewById(R.id.textview2);
       textView3=customView.findViewById(R.id.textview3);
       textView4=customView.findViewById(R.id.textview4);

   }

Please help me.....

Harish
  • 237
  • 2
  • 10
  • 1
    Hae you tried [this](https://stackoverflow.com/questions/3221488/blur-or-dim-background-when-android-popupwindow-active)? – Nilesh Panchal Feb 14 '19 at 06:01
  • Using that code its dimming entire screen, But I want to like the attached image. – Harish Feb 14 '19 at 06:14
  • I assume that you are going to make your image as a background image with a dim effect am I correct? – Nilesh Panchal Feb 14 '19 at 06:17
  • NO, when I do a long press it will open the popup window, except selected view and popup window remaining all views should blur or dim. the above mentioned code is dimming entire screen with my selected view also. – Harish Feb 14 '19 at 06:20

0 Answers0