I have created my PopupWindow
using a simple LinearLayout
with a background color. There is a shadow on the PopupWindow
. How do I remove the shadow automatically generated for the PopupWindow
. I created a 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:
Is it possible that you are missing some code there? I'm not seeing that you are adding the pop to the view.
Anyway, to remove the shadow you have to use this line of code in the PopupWindow:
this.getWindow().setBackgroundDrawable(new ColorDrawable(0));
At least that's what worked for me...
Cheers!
You can style PopupWindows in your application. This code simply removes native shadows from all your PopupWindows
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With