Skip to content

Commit f5d6023

Browse files
overlay run with alphaAnimation, sample app update
1 parent 3320dad commit f5d6023

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

sample/src/main/java/com/yuyakaido/android/cardstackview/sample/MainActivity.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,10 @@ public void swipeLeft() {
208208
}
209209

210210
View target = cardStackView.getTopView();
211+
View targetOverlay = cardStackView.getTopView().getOverlayContainer();
211212

212213
ValueAnimator rotation = ObjectAnimator.ofPropertyValuesHolder(
213-
target, PropertyValuesHolder.ofFloat("rotation", -10f));
214+
target, PropertyValuesHolder.ofFloat("rotation", 10f));
214215
rotation.setDuration(200);
215216
ValueAnimator translateX = ObjectAnimator.ofPropertyValuesHolder(
216217
target, PropertyValuesHolder.ofFloat("translationX", 0f, -2000f));
@@ -220,10 +221,15 @@ public void swipeLeft() {
220221
translateY.setStartDelay(100);
221222
translateX.setDuration(500);
222223
translateY.setDuration(500);
223-
AnimatorSet set = new AnimatorSet();
224-
set.playTogether(rotation, translateX, translateY);
224+
AnimatorSet cardAnimationSet = new AnimatorSet();
225+
cardAnimationSet.playTogether(rotation, translateX, translateY);
226+
227+
ObjectAnimator overlayAnimator = ObjectAnimator.ofFloat(targetOverlay, "alpha", 0f, 1f);
228+
overlayAnimator.setDuration(200);
229+
AnimatorSet overlayAnimationSet = new AnimatorSet();
230+
overlayAnimationSet.playTogether(overlayAnimator);
225231

226-
cardStackView.swipe(SwipeDirection.Left, set);
232+
cardStackView.swipe(SwipeDirection.Left, cardAnimationSet, overlayAnimationSet);
227233
}
228234

229235
public void swipeRight() {
@@ -233,9 +239,10 @@ public void swipeRight() {
233239
}
234240

235241
View target = cardStackView.getTopView();
242+
View targetOverlay = cardStackView.getTopView().getOverlayContainer();
236243

237244
ValueAnimator rotation = ObjectAnimator.ofPropertyValuesHolder(
238-
target, PropertyValuesHolder.ofFloat("rotation", 10f));
245+
target, PropertyValuesHolder.ofFloat("rotation", -10f));
239246
rotation.setDuration(200);
240247
ValueAnimator translateX = ObjectAnimator.ofPropertyValuesHolder(
241248
target, PropertyValuesHolder.ofFloat("translationX", 0f, 2000f));
@@ -245,10 +252,15 @@ public void swipeRight() {
245252
translateY.setStartDelay(100);
246253
translateX.setDuration(500);
247254
translateY.setDuration(500);
248-
AnimatorSet set = new AnimatorSet();
249-
set.playTogether(rotation, translateX, translateY);
255+
AnimatorSet cardAnimationSet = new AnimatorSet();
256+
cardAnimationSet.playTogether(rotation, translateX, translateY);
257+
258+
ObjectAnimator overlayAnimator = ObjectAnimator.ofFloat(targetOverlay, "alpha", 0f, 1f);
259+
overlayAnimator.setDuration(200);
260+
AnimatorSet overlayAnimationSet = new AnimatorSet();
261+
overlayAnimationSet.playTogether(overlayAnimator);
250262

251-
cardStackView.swipe(SwipeDirection.Right, set);
263+
cardStackView.swipe(SwipeDirection.Right, cardAnimationSet, overlayAnimationSet);
252264
}
253265

254266
private void reverse() {

0 commit comments

Comments
 (0)