title: Change popup menu style - not working
body: <p>I'm trying to apply style to Android popup menu. Menu is shown on button click. In my example I want to set black menu background.</p>
  
  <p>So, my menu layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;item
          android:title="Item 1"
          android:id="@+id/menu1"&gt;
      &lt;/item&gt;
  
      &lt;item
          android:title="Item 2"
          android:id="@+id/menu2"&gt;
      &lt;/item&gt;
  
  &lt;/menu&gt;
  </code></pre>
  
  <p>Next, my activity layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context="com.example.michal.popupmenu.MainActivity"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Hello World!"/&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="New Button"
          android:id="@+id/button"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"
          android:onClick="btnClick"
          android:nestedScrollingEnabled="true"/&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Code to show menu on button click:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity
  {
  
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
      }
  
      public void btnClick(View view)
      {
          showMenu(view);
  
      }
  
  
      public void showMenu(View v)
      {
          PopupMenu popup = new PopupMenu(this, v);
          popup.inflate(R.menu.popup_menu);
          popup.show();
      }
  }
  </code></pre>
  
  <p>Styles xmle was generated automatically. I have only added menu style to set black menu background, here it is:
  </p>
  
  <pre><code>&lt;style name="PopupMenu" parent="Widget.AppCompat.PopupMenu"&gt;
      &lt;item name="android:popupBackground"&gt;@android:color/black&lt;/item&gt;
  
  &lt;/style&gt;
  
  &lt;!-- Base application theme. --&gt;
  &lt;style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"&gt;
      &lt;!-- Customize your theme here. --&gt;
      &lt;item name="colorPrimary"&gt;@color/colorPrimary&lt;/item&gt;
      &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark&lt;/item&gt;
      &lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt;
      &lt;item name="popupMenuStyle"&gt;@style/PopupMenu&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p></p>
  
  <p>But still menu background is white and it should be black. Any ideas what's wrong?</p>
  
  <p>[edit]
  According to comments, updated code:</p>
  
  <pre><code>&lt;resources&gt;
  
      &lt;style name="PopupMenu" parent="@style/Widget.AppCompat.Light.PopupMenu"&gt;
          &lt;item name="android:popupBackground"&gt;#FF4081&lt;/item&gt;
      &lt;/style&gt;
  
      &lt;!-- Base application theme. --&gt;
      &lt;style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"&gt;
          &lt;!-- Customize your theme here. --&gt;
          &lt;item name="colorPrimary"&gt;@color/colorPrimary&lt;/item&gt;
          &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark&lt;/item&gt;
          &lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt;
      &lt;/style&gt;
  
  
  
  &lt;/resources&gt;
  </code></pre>
  
  <p>Main activity:</p>
  
  <pre><code>public void showMenu(View v)
      {
          Context wrapper = new ContextThemeWrapper(getApplicationContext(), R.style.PopupMenu);
          PopupMenu popup = new PopupMenu(wrapper, v);
  
          // This activity implements OnMenuItemClickListener
          //popup.setOnMenuItemClickListener((PopupMenu.OnMenuItemClickListener) this);
          popup.inflate(R.menu.popup_menu);
          popup.show();
      }
  </code></pre>
  
  <p>Result is not what I expect</p>
  
  <p><a href="https://i.stack.imgur.com/uepk1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uepk1.png" alt="result"></a></p>
  
  <p>Menu background is still black, not a color I want to set.</p>