@@ -128,6 +128,7 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
128128 protected static final String KEY_SNAPSHOT = "shared_element:bitmap" ;
129129 protected static final String KEY_SCALE_TYPE = "shared_element:scaleType" ;
130130 protected static final String KEY_IMAGE_MATRIX = "shared_element:imageMatrix" ;
131+ protected static final String KEY_ELEVATION = "shared_element:elevation" ;
131132
132133 protected static final ImageView .ScaleType [] SCALE_TYPE_VALUES = ImageView .ScaleType .values ();
133134
@@ -393,6 +394,8 @@ private void setSharedElementState(View view, String name, Bundle transitionArgs
393394
394395 float z = sharedElementBundle .getFloat (KEY_TRANSLATION_Z );
395396 view .setTranslationZ (z );
397+ float elevation = sharedElementBundle .getFloat (KEY_ELEVATION );
398+ view .setElevation (elevation );
396399
397400 float left = sharedElementBundle .getFloat (KEY_SCREEN_LEFT );
398401 float top = sharedElementBundle .getFloat (KEY_SCREEN_TOP );
@@ -499,6 +502,8 @@ private static SharedElementOriginalState getOldSharedElementState(View view, St
499502 state .mBottom = view .getBottom ();
500503 state .mMeasuredWidth = view .getMeasuredWidth ();
501504 state .mMeasuredHeight = view .getMeasuredHeight ();
505+ state .mTranslationZ = view .getTranslationZ ();
506+ state .mElevation = view .getElevation ();
502507 if (!(view instanceof ImageView )) {
503508 return state ;
504509 }
@@ -557,7 +562,9 @@ protected static void setOriginalSharedElementState(ArrayList<View> sharedElemen
557562 imageView .setImageMatrix (state .mMatrix );
558563 }
559564 }
560- int widthSpec = View .MeasureSpec .makeMeasureSpec (state .mMeasuredWidth ,
565+ view .setElevation (state .mElevation );
566+ view .setTranslationZ (state .mTranslationZ );
567+ int widthSpec = View .MeasureSpec .makeMeasureSpec (state .mMeasuredWidth ,
561568 View .MeasureSpec .EXACTLY );
562569 int heightSpec = View .MeasureSpec .makeMeasureSpec (state .mMeasuredHeight ,
563570 View .MeasureSpec .EXACTLY );
@@ -622,6 +629,7 @@ protected void captureSharedElementState(View view, String name, Bundle transiti
622629 sharedElementBundle .putFloat (KEY_SCREEN_TOP , tempBounds .top );
623630 sharedElementBundle .putFloat (KEY_SCREEN_BOTTOM , tempBounds .bottom );
624631 sharedElementBundle .putFloat (KEY_TRANSLATION_Z , view .getTranslationZ ());
632+ sharedElementBundle .putFloat (KEY_ELEVATION , view .getElevation ());
625633
626634 Parcelable bitmap = mListener .captureSharedElementSnapshot (view , tempMatrix , tempBounds );
627635 if (bitmap != null ) {
@@ -801,5 +809,7 @@ static class SharedElementOriginalState {
801809 int mMeasuredHeight ;
802810 ImageView .ScaleType mScaleType ;
803811 Matrix mMatrix ;
812+ float mTranslationZ ;
813+ float mElevation ;
804814 }
805815}
0 commit comments