2012-12-19 52 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>