title: Sliding layer activity animation android
body: <p>I want to implement sliding-layer animation for activity transition as described in material design guidelines.</p>
  
  <p><img src="https://i.stack.imgur.com/hJdX0.gif" alt="Material Transition"></p>
  
  <p>However, all I could do by now is a simple combination of slide_in and stay animation which doesn't give me a stacked layer kind of effect. How can I achieve it?</p>
  
  <p><strong>My current implementation :</strong></p>
  
  <p><em>On Activity Start:</em></p>
  
  <pre><code>activity.overridePendingTransition(R.anim.slide_in_right, R.anim.stay);
  </code></pre>
  
  <p><em>On Activity Close:</em></p>
  
  <pre><code>activity.overridePendingTransition(R.anim.stay, R.anim.slide_out_right);
  </code></pre>
  
  <p><em>slide_in_right.xml:</em></p>
  
  <pre><code>&lt;set xmlns:android="http://schemas.android.com/apk/res/android"
      android:interpolator="@android:anim/accelerate_interpolator"&gt;
      &lt;translate
          android:fromXDelta="100%p"
          android:toXDelta="0"
          android:duration="@android:integer/config_shortAnimTime" /&gt;
  &lt;/set&gt;
  </code></pre>
  
  <p><em>slide_out_right.xml:</em></p>
  
  <pre><code>&lt;set xmlns:android="http://schemas.android.com/apk/res/android"
      android:interpolator="@android:anim/accelerate_interpolator"&gt;
      &lt;translate
          android:fromXDelta="0"
          android:toXDelta="100%p"
          android:duration="@android:integer/config_shortAnimTime" /&gt;
  &lt;/set&gt;
  </code></pre>
  
  <p><em>stay.xml:</em></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;translate xmlns:android="http://schemas.android.com/apk/res/android"
      android:duration="@android:integer/config_shortAnimTime"
      android:fromYDelta="0%p"
      android:toYDelta="0%p" /&gt;
  </code></pre>