翻转动画

Flip Up Animation

我正在尝试在 Android 中制作翻转动画。 我正在使用此代码:

<set xmlns:android="http://schemas.android.com/apk/res/android">
  <!-- Set alpha to 0 before animation -->
  <objectAnimator
    android:valueFrom="1.0"
    android:valueTo="0.0"
    android:propertyName="alpha"
    android:duration="0"/>

  <!-- Rotate -->
  <objectAnimator
    android:valueFrom="180"
    android:valueTo="0"
    android:propertyName="rotationY"
    android:interpolator="@android:interpolator/accelerate_decelerate"
    android:duration="@integer/card_flip_time_full"/>

  <!-- Half-way through the rotation set the alpha to 1 -->
  <objectAnimator
    android:valueFrom="0.0"
    android:valueTo="1.0"
    android:propertyName="alpha"
    android:startOffset="@integer/card_flip_time_half"
    android:duration="1"/>
</set>

但是,我希望它从上到下翻转。像这样:

我该怎么做?

您可以通过编程方式完成。这是 Xamarin 的 C#。现在无法测试 Java,但它会非常相似。

ImageView block = FindViewById<ImageView>(Resource.Id.imgBlock);
ObjectAnimator blockSpin = ObjectAnimator.OfFloat(block, "rotationX", 0, 360);
imageCard.PivotX = 0.5f; //so it spins on center

float scale = metrics.Density;
imageCard.SetCameraDistance(8000*scale);
  /*Set camera distance as required to avoid distortion. 
     Multiplying by scale keeps distance the same across devices. */
blockSpin.SetDuration(500);
blockSpin.Start();