1

I am trying to apply card flip animation on ViewGroup inside PopupWindow. I am using AnimatorSet to apply animation over ViewGroup. Animation is happening within the bounds of the window. And part of window going out of window bounds are clipping. Any suggestions to avoid clipping?

I have found solution, but other solutions are welcome. :)

Swaroop
  • 532
  • 1
  • 4
  • 16

1 Answers1

1

I used scalX and scalY properties of objectAnimator. When animation starts, I scale down window from value 0.9 to 0.5 for half of animation time. And again scale window from 0.5 to 0.9 for remaining animation time. As window size is reduced, window bounds perfectly fit inside clipping region during animation. This solved my problem. Below is the additional code in card_flip_right_out.xml from this example

    <objectAnimator
        android:duration="200"
        android:propertyName="scaleY"
        android:valueFrom="0.9"
        android:valueTo="0.5" >
    </objectAnimator>
    <objectAnimator
        android:duration="200"
        android:propertyName="scaleX"
        android:valueFrom="0.9"
        android:valueTo="0.5" >
    </objectAnimator>

Below code added in card_flip_right_in.xml

<objectAnimator
    android:duration="199"
    android:propertyName="scaleY"
    android:valueFrom="0.5"
    android:valueTo="0.9" >
</objectAnimator>
<objectAnimator
    android:duration="199"
    android:propertyName="scaleX"
    android:valueFrom="0.5"
    android:valueTo="0.9" >
</objectAnimator>
<objectAnimator
      android:duration="1"
    android:propertyName="scaleY" 
    android:startOffset="199"
    android:valueTo="1" >
</objectAnimator>
<objectAnimator
    android:duration="1"
    android:propertyName="scaleX"
    android:startOffset="199"
    android:valueTo="1" >
Piyush
  • 18,895
  • 5
  • 32
  • 63
Swaroop
  • 532
  • 1
  • 4
  • 16