如何更改PopupMenu背景的颜色

时间:2015-05-14 13:45:36

标签: android popup

我使用以下代码创建弹出菜单.. 我需要改变菜单的背景颜色..我怎么能这样做。请帮忙。

//Creating the instance of PopupMenu  
            PopupMenu popup = new PopupMenu(ctx, holder.ll_overflow);  
            //Inflating the Popup using xml file  
            popup.getMenuInflater().inflate(R.menu.bday_contacts_menu, popup.getMenu());  

            //registering popup with OnMenuItemClickListener  
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {  

            @Override
            public boolean onMenuItemClick(MenuItem item) {



                return true;
            }

            });  

            popup.show();//showing popup menu  

1 个答案:

答案 0 :(得分:3)

您可以使用样式

进行更改
   <style name="AppBaseTheme" parent="@android:style/Theme.Light.NoTitleBar">

</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:popupMenuStyle">@style/PopupMenu</item>    
</style>

<style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@android:color/white</item>
<item name="android:textColor">#FF01F0</item>
<item name="android:textSize">12sp</item>
</style>