title: Shared Elements Transition with nested views
body: <p>I put together a simple sample app to try shared elements transition with nested views (<a href="https://github.com/Longi94/SharedElementsTest/tree/46c7f23b0df9b1cf347d173196db1f47f4ae35e9" rel="nofollow noreferrer">source code on github</a>). In this case it's an ImageView inside a CardView. I got the following results:</p>
  
  <p><a href="https://i.stack.imgur.com/ZnUZX.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZnUZX.gif" alt="image"></a></p>
  
  <p>As you can see, while the parent view (CardView) animates nicely the child view (ImageView) doesn't. It looks like it animates from the upper left corner of the future position of the CardView.</p>
  
  <p><strong>The Adapter</strong></p>
  
  <pre><code>@Override
  public View getView(final int position, View convertView, ViewGroup parent) {
      final View v = mInflater.inflate(R.layout.grid_item, null);
  
      v.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent i = new Intent(new Intent(mContext, DialogActivity.class));
              ActivityOptions options = ActivityOptions
                      .makeSceneTransitionAnimation((Activity) mContext,
                              Pair.create(v, "background_transition"),
                              Pair.create(v.findViewById(R.id.image), "image_transition"));
              mContext.startActivity(i, options.toBundle());
          }
      });
  
      return v;
  }
  </code></pre>
  
  <p><strong>The original layout</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:card_view="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_margin="1.5dp"
      android:transitionName="background_transition"
      card_view:cardBackgroundColor="@android:color/holo_red_dark"&gt;
  
      &lt;com.tlongdev.sharedelementstest.SquareImageLayout
          android:id="@+id/image"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:transitionName="image_transition"
          android:src="@android:drawable/btn_star_big_on"/&gt;
  
  &lt;/android.support.v7.widget.CardView&gt;
  </code></pre>
  
  <p><strong>The target layout</strong></p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:card_view="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:gravity="center"
      tools:context="com.tlongdev.sharedelementstest.DialogActivity"&gt;
  
      &lt;android.support.v7.widget.CardView
          android:id="@+id/card"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          card_view:cardBackgroundColor="@android:color/holo_red_dark"
          card_view:cardCornerRadius="4dp"
          card_view:cardElevation="10dp"
          android:transitionName="background_transition"&gt;
  
          &lt;com.tlongdev.sharedelementstest.SquareImageLayout
              android:layout_margin="25dp"
              android:layout_width="100dp"
              android:layout_height="100dp"
              android:src="@android:drawable/btn_star_big_on"
              android:transitionName="image_transition" /&gt;
  
      &lt;/android.support.v7.widget.CardView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Any help would be appreciated.</p>
  
  <p><strong>UPDATE 16/11/15:</strong> It looks like this issue has been solved on Marshmallow, but still present on Lollipop (on a emulator at least).</p>