@@ -131,6 +131,7 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
131131 protected static final String KEY_BITMAP = "shared_element:bitmap" ;
132132 protected static final String KEY_SCALE_TYPE = "shared_element:scaleType" ;
133133 protected static final String KEY_IMAGE_MATRIX = "shared_element:imageMatrix" ;
134+ protected static final String KEY_ELEVATION = "shared_element:elevation" ;
134135
135136 protected static final ImageView .ScaleType [] SCALE_TYPE_VALUES = ImageView .ScaleType .values ();
136137
@@ -396,6 +397,8 @@ private void setSharedElementState(View view, String name, Bundle transitionArgs
396397
397398 float z = sharedElementBundle .getFloat (KEY_TRANSLATION_Z );
398399 view .setTranslationZ (z );
400+ float elevation = sharedElementBundle .getFloat (KEY_ELEVATION );
401+ view .setElevation (elevation );
399402
400403 float left = sharedElementBundle .getFloat (KEY_SCREEN_LEFT );
401404 float top = sharedElementBundle .getFloat (KEY_SCREEN_TOP );
@@ -500,6 +503,8 @@ private static SharedElementOriginalState getOldSharedElementState(View view, St
500503 state .mBottom = view .getBottom ();
501504 state .mMeasuredWidth = view .getMeasuredWidth ();
502505 state .mMeasuredHeight = view .getMeasuredHeight ();
506+ state .mTranslationZ = view .getTranslationZ ();
507+ state .mElevation = view .getElevation ();
503508 if (!(view instanceof ImageView )) {
504509 return state ;
505510 }
@@ -558,7 +563,9 @@ protected static void setOriginalSharedElementState(ArrayList<View> sharedElemen
558563 imageView .setImageMatrix (state .mMatrix );
559564 }
560565 }
561- int widthSpec = View .MeasureSpec .makeMeasureSpec (state .mMeasuredWidth ,
566+ view .setElevation (state .mElevation );
567+ view .setTranslationZ (state .mTranslationZ );
568+ int widthSpec = View .MeasureSpec .makeMeasureSpec (state .mMeasuredWidth ,
562569 View .MeasureSpec .EXACTLY );
563570 int heightSpec = View .MeasureSpec .makeMeasureSpec (state .mMeasuredHeight ,
564571 View .MeasureSpec .EXACTLY );
@@ -623,6 +630,7 @@ protected static void captureSharedElementState(View view, String name, Bundle t
623630 sharedElementBundle .putFloat (KEY_SCREEN_TOP , tempBounds .top );
624631 sharedElementBundle .putFloat (KEY_SCREEN_BOTTOM , tempBounds .bottom );
625632 sharedElementBundle .putFloat (KEY_TRANSLATION_Z , view .getTranslationZ ());
633+ sharedElementBundle .putFloat (KEY_ELEVATION , view .getElevation ());
626634
627635 int bitmapWidth = Math .round (tempBounds .width ());
628636 int bitmapHeight = Math .round (tempBounds .height ());
@@ -806,5 +814,7 @@ static class SharedElementOriginalState {
806814 int mMeasuredHeight ;
807815 ImageView .ScaleType mScaleType ;
808816 Matrix mMatrix ;
817+ float mTranslationZ ;
818+ float mElevation ;
809819 }
810820}
0 commit comments