RandomUser
RandomUser

Reputation: 13

how to change the color of PopupMenu background

I am using the following code for creating pop up menu.. i need to change the background color of the menu.. how can i do that. please help.

//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  

Upvotes: 1

Views: 2088

Answers (1)

Ravitheja
Ravitheja

Reputation: 781

You can change it using styles

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

Upvotes: 3

Related Questions