tenten tenten - 1 year ago 102
Android Question

Android popup with gray background

I have implemented a Popup menu for a image button. Popup background is blue. I want change it to gray. Please help me on this.

My Code :

btn_a.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
PopupMenu a_popup = new PopupMenu(getActivity().getApplicationContext(), a_period);
a_popup.getMenuInflater().inflate(R.menu.popup_a, a_popup.getMenu());

a_popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {

public boolean onMenuItemClick(MenuItem item) {
Toast.makeText(getActivity().getApplicationContext(), "Clicked "+item.getTitle(), Toast.LENGTH_SHORT).show();
return true;

Answer Source

You can use Style like this and use "MyTheme" style in your activity or from the whole application.

<style name="MyTheme" parent="android:Theme.Light">
   <item name="android:popupMenuStyle">@style/PopupMenu</item>

<style name="popMenu" parent="@android:style/Widget.PopupMenu">
   <item name="android:popupBackground">@android:color/white</item>