title: Why is Android inverting some of my drawables for dark theme (night) but not others?
body: <p>My app uses the <code>Theme.AppCompat.DayNight.NoActionBar</code> <code>AppTheme</code>, and has a navigation drawer. All my drawables are XML vectors and the paths in them are black. For the uses of these drawables that are in the menu in my sidenav, something somewhere in Android or the SDK has inverted the drawable such that my paths are in fact white (or a colour close to white, maybe it's actually <code>colorAccent</code>). This is good.</p>
  <p>But when I place the same drawable myself in the action bar as a menu item, it isn't inverted and still uses the black path. How come? How do I get the same magic happening there?</p>
  <p>Theme:</p>
  <pre><code>&lt;style name=&quot;AppTheme&quot; parent=&quot;Theme.AppCompat.DayNight.NoActionBar&quot;&gt;
      &lt;item name=&quot;colorAccent&quot;&gt;@color/primaryTextColor&lt;/item&gt;
      &lt;item name=&quot;android:navigationBarColor&quot;&gt;#00000000&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  <p>Action bar in the main activity layout:</p>
  <pre><code>&lt;androidx.appcompat.widget.Toolbar
          android:id=&quot;@+id/toolbar&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot; /&gt;
  </code></pre>
  <p><code>menu/action_bar.xml</code>:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;&gt;
  
      &lt;item android:id=&quot;@+id/bookmarkAction&quot;
          android:title=&quot;@string/bookmark&quot;
          android:icon=&quot;@drawable/ic_bookmark_off&quot;
          app:showAsAction=&quot;always&quot;
          tools:ignore=&quot;AlwaysShowAction&quot; /&gt;
  &lt;/menu&gt;
  </code></pre>
  <p>Here's how I inflate the menu and handle the toggling of the bookmark from the fragment (a <code>ToggleButton</code> did not seem like it would save me any work here):</p>
  <pre><code>override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
      inflater.inflate(R.menu.action_bar, menu)
      super.onCreateOptionsMenu(menu, inflater)
  }
  
  // Swap out the bookmark icon in the options menu depending
  // on whether this command is bookmarked or not.
  override fun onPrepareOptionsMenu(menu: Menu) {
      super.onPrepareOptionsMenu(menu)
  
      val bookmarkMenuItem = menu.getItem(0)
      val commandName = viewModel.command.value?.name
  
      if (model?.bookmarkedCommands?.contains(commandName)!!) {
          Log.v(logTag, &quot;${commandName} is bookmarked&quot;)
  
          bookmarkMenuItem?.icon = ContextCompat.getDrawable(requireContext(),
              R.drawable.ic_bookmark_on)
      }
      else {
          Log.v(logTag, &quot;${commandName} is not bookmarked&quot;)
  
          bookmarkMenuItem?.icon = ContextCompat.getDrawable(requireContext(),
              R.drawable.ic_bookmark_off)
      }
  }
  </code></pre>
  <p>Sidenav icons, inverted (good):</p>
  <p><a href="https://i.stack.imgur.com/JJOlE.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/JJOlE.jpg" alt="sidenav" /></a></p>
  <p>Action bar icon, not inverted (bad):</p>
  <p><a href="https://i.stack.imgur.com/6fQSG.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/6fQSG.jpg" alt="enter image description here" /></a></p>