2012-12-19 47 views
4

我使用简单的LinearLayout创建了我的PopupWindow背景颜色。 PopupWindow上有一个影子。如何删除为PopupWindow自动生成的阴影。我创建了一个PopupWindow有以下几点:在Android中删除阴影PopupWindow

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);  

截图:

popup shadow

+0

您是否可以添加屏幕截图? –

+0

我添加了screeenshot – prostock

回答

12

有没有可能是你缺少一些代码吗?我没有看到您将流行音乐添加到视图中。

总之,去除阴影,你必须使用这行代码在PopupWindow:

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

至少这是对我工作......

干杯!

+0

优秀的男人!!谢谢 –

+0

但无法看到popupwindow的海拔 –

0

您可以在应用程序中设计PopupWindows风格。此代码只是从您所有的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>