title: Android 5.0 - Animate the AppCompat v7 21 home icon from burger to back arrow programmatically
body: <p>I'm currently updating a <code>Fragment</code> oriented app (I have one <code>Activity</code> with a <code>FrameLayout</code> container as host for all my <code>Fragment</code>s) to Material Design. And I would like to animate the burger icon to the back arrow when replacing a <code>Fragment</code>.</p>
  
  <p>Basically, if this wasn't clear enough, <a href="http://material-design.storage.googleapis.com/publish/v_1/quantumexternal/0B0NGgBg38lWWNkJYYXZvcGFXZDg/animation-responsiveinteraction-userinput-030201_Radial_Reaction_xhdpi_001.webm" rel="nofollow noreferrer"><strong>here</strong></a> is what I want to achieve. I don't want to use <a href="https://github.com/balysv/material-menu" rel="nofollow noreferrer"><strong>this library (MaterialMenu)</strong></a>, I'd like to use the official <code>AppCompat</code> lib to the extend of possible.</p>
  
  <p>I achieved this effect thanks to <a href="https://stackoverflow.com/a/26480439/3108590"><strong>this solution</strong></a>, but I can't figure out how to make to <code>ActionBarDrawerToggle</code> as a back button when a <code>Fragment</code> is replaced.</p>
  
  <p>So my questions is : should the back arrow icon still be the <code>ActionBarDrawerToggle</code>once the <code>Fragement</code> has been replaced? In which case how do I override it so it acts like <code>onBackPressed()</code> instead of openning the drawer ? I already tried this but it doesn't work :</p>
  
  <pre><code> @Override
      public boolean onOptionsItemSelected(MenuItem item)
      {
          switch (item.getItemId())
          {
              case android.R.id.home:
                  getActivity().onBackPressed();
                  return true;
           }
           return false;
      }
  </code></pre>
  
  <p>Thanks in advance.</p>