Remove shadow in Android PopupWindow

I created my PopupWindow using a simple LinearLayout with background color. There is a shadow on PopupWindow . How to remove a shadow automatically created for PopupWindow . I created PopupWindow with the following:

  View view = LayoutInflater.from(getBaseContext()).inflate(R.layout.mylayout,null); pop = new PopupWindow(this); pop.setTouchable(false); pop.setHeight(200); pop.setWidth(200); pop.setContentView(view); pop.showAtLocation(parentview, 0, 50, 50); 

Screenshot:

popup shadow

+4
source share
2 answers

Is it possible that the code is missing there? I do not see that you are adding pop to the view.

In any case, to remove the shadow, you must use this line of code in PopupWindow:

 this.getWindow().setBackgroundDrawable(new ColorDrawable(0)); 

At least what worked for me ...

Hooray!

+12
source

You can create PopupWindows in your application. This code simply removes your own shadows from all of your popups.

 <style name="Base.AppTheme" parent="Theme.AppCompat.Light"> <item name="android:popupMenuStyle">@style/PopupMenu</item> </style> <style name="PopupMenu" parent="android:Widget.Material.PopupMenu"> <item name="android:popupElevation">0dp</item> </style> 
0
source

All Articles