title: AppCompat style background propagated to the Image within the ToolBar
body: <p><strong>Context</strong></p>
  
  <p>I'm using the newest AppCompat v7 lib (21.0.0) and I have migrated my app from ActionBar to ToolBar</p>
  
  <p><strong>Problem</strong></p>
  
  <ol>
  <li>Images in the ToolBar automatically receive the same background as the ToolBar</li>
  </ol>
  
  <p>Currently the SearchBox is a custom view set on the action bar (From previous implementation) I plan to switch if to the SearchView and style it accordingly but I'm still very interested in the problem I'm facing right now.</p>
  
  <p><img src="https://i.stack.imgur.com/eVodp.png" alt="Img background"></p>
  
  <ol start="2">
  <li>When long pressing on a menu item in the ToolBar a toast appear with the hint text and the text has the same background than the ToolBar.</li>
  </ol>
  
  <p><img src="https://i.stack.imgur.com/nHcdd.png" alt="Toast background"></p>
  
  <p>How can I avoid this?</p>
  
  <p>Here is my toolbar layout and the style &amp; theme</p>
  
  <p>layout v_toolbar.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.Toolbar
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/my_awesome_toolbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
      app:theme="@style/MyActionBarStyle"/&gt;
  </code></pre>
  
  <p>values/styles.xml</p>
  
  <pre><code>&lt;style name="MyActionBarStyle" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt;
      &lt;item name="android:background"&gt;@color/green&lt;/item&gt;
      &lt;item name="android:windowActionBarOverlay"&gt;true&lt;/item&gt;
  
      &lt;!-- Support library compatibility --&gt;
      &lt;item name="background"&gt;@color/green&lt;/item&gt;
      &lt;item name="windowActionBarOverlay"&gt;true&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>Theme</p>
  
  <pre><code>&lt;style name="MyTheme" parent="AppBaseTheme"&gt;
      &lt;!-- Here we setting appcompat’s actionBarStyle --&gt;
      &lt;!-- &lt;item name="actionBarStyle"&gt;@style/MyActionBarStyle&lt;/item&gt; --&gt;
  
      &lt;item name="windowActionBar"&gt;false&lt;/item&gt;
      &lt;!-- ...and here we setting appcompat’s color theming attrs --&gt;
      &lt;item name="colorPrimary"&gt;@color/green&lt;/item&gt;
      &lt;item name="colorPrimaryDark"&gt;@color/green_dark&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p><strike><strong>Workaround 1 for problem 1</strong></p>
  
  <p>The workaround for the first problem is to set a transparent background on the ImageView</p>
  
  <pre><code>android:background="@color/transparent"
  </code></pre>
  
  <p>This does not solve the toast issue.</strike></p>
  
  <p><strong>Solution for both problems</strong></p>
  
  <p>I set a background to the ToolBar</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.Toolbar
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/my_awesome_toolbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@color/green"
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
      app:theme="@style/MyActionBarStyle"/&gt;
  </code></pre>
  
  <p>And I'm not setting the background on the theme anymore.</p>
  
  <pre><code>&lt;style name="MyActionBarStyle" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt;
      &lt;item name="android:windowActionBarOverlay"&gt;true&lt;/item&gt;
      &lt;!-- Support library compatibility --&gt;
      &lt;item name="windowActionBarOverlay"&gt;true&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>As pointed by Chris Banes, a style could be created for the toolbar instead of declaring the android:background.</p>
  
  <p>This fixes my problem but then I seem to have another issue with the fact that the popupTheme isn't applied and my ShareActionMenuItem drop down does not have a white background with black text.
  See another question here: <a href="https://stackoverflow.com/q/26504532/1228221">AppCompat ToolBar popupTheme not used in the ShareAction MenuItem</a></p>
  
  <p>Maybe this is a bug in the appcompat library.</p>