@@ -150,14 +150,23 @@ private class AnimationHelper {
150150 public int startBottom ;
151151 public int endBottom ;
152152
153+ public int startPaddingLeft ;
154+ public int endPaddingLeft ;
155+ public int startPaddingRight ;
156+ public int endPaddingRight ;
157+ public int startPaddingTop ;
158+ public int endPaddingTop ;
159+ public int startPaddingBottom ;
160+ public int endPaddingBottom ;
161+
153162 public float startRadius ;
154163 public float endRadius ;
155164
156165 public @ ColorInt int startColor ;
157166 public @ ColorInt int endColor ;
158167 private ArgbEvaluator mArgbEvaluator = new ArgbEvaluator ();
159168
160- public static final long ANIMATION_DURATION_CARD = 5000L ;
169+ public static final long ANIMATION_DURATION_CARD = 500L ;
161170 public static final long ANIMATION_DURATION_ALPHA = 300L ;
162171
163172 public AnimationHelper (View view , int index ) {
@@ -171,10 +180,17 @@ public AnimationHelper(View view, int index) {
171180 startTop = mCardView .getTop ();
172181 startBottom = mCardView .getBottom ();
173182
174- endLeft = 0 ;
175- endRight = mCardView .getWidth () + 2 * mCardView .getLeft ();
176- endTop = 0 ;
177- endBottom = mCardView .getHeight ();
183+ endLeft = -mCardView .getPaddingLeft ();
184+ endRight = mCardView .getWidth () + 2 * mCardView .getLeft () + mCardView .getPaddingRight ();
185+ endTop = -mCardView .getPaddingTop ();
186+ endBottom = mCardView .getHeight () - mCardView .getPaddingTop ();
187+
188+ startPaddingLeft = mCardView .getPaddingLeft ();
189+ startPaddingRight = mCardView .getPaddingRight ();
190+ startPaddingTop = mCardView .getPaddingTop ();
191+ startPaddingBottom = mCardView .getPaddingBottom ();
192+
193+ endPaddingLeft = endPaddingRight = endPaddingTop = endPaddingBottom = 0 ;
178194
179195 startRadius = mCardView .getRadius ();
180196 endRadius = 1f ;// radius 减到 0 会自动产生透明度变化
@@ -221,6 +237,7 @@ public void onAnimationUpdate(ValueAnimator animation) {
221237 animator .addListener (new Animator .AnimatorListener () {
222238 @ Override
223239 public void onAnimationStart (Animator animation ) {
240+ mCardStackView .setSkipLayout (true );
224241 if (!reverse ) {
225242 mTitle .animate ().alpha (0f ).setDuration (ANIMATION_DURATION_ALPHA ).start ();
226243 mToolbar .animate ().alpha (0f ).setDuration (ANIMATION_DURATION_ALPHA ).start ();
@@ -237,9 +254,16 @@ public void onAnimationEnd(Animator animation) {
237254 } else {
238255 Intent intent = new Intent (MainActivity .this , DetailActivity .class );
239256 intent .putExtra ("card" , mCards .get (mIndex ));
257+ intent .putExtra ("padding" , startPaddingBottom );
240258 startActivityForResult (intent , REQ_DETAIL );
241259 overridePendingTransition (0 , 0 );
242260 }
261+ mCardStackView .post (new Runnable () {
262+ @ Override
263+ public void run () {
264+ mCardStackView .setSkipLayout (false );
265+ }
266+ });
243267 }
244268
245269 @ Override
@@ -273,7 +297,6 @@ public void resetViews() {
273297 }
274298
275299 update (0f );
276- //mImageView.postInvalidate();
277300 mTitle .setAlpha (1f );
278301 mToolbar .setAlpha (1f );
279302 }
0 commit comments