4

嗨,我将使用支持的 jar 文件在 android 中开发片段事务之间的翻转动画。因为我想为较低版本实现片段。我找到了翻转动画的 android开发者教程。但是支持的库不支持Objactor 动画。搜索互联网后我发现我需要将 objacter 动画更改为Tween 动画. .如何将这些 xml 文件更改为像下面这样的补间动画。

card_flip_left_in.xml

  <!-- Before rotating, immediately set the alpha to 0. -->
 <alpha
    android:valueFrom="1.0"
    android:valueTo="0.0"
    android:propertyName="alpha"
    android:duration="0" />

 <!-- Rotate. -->
 <rotate
    android:valueFrom="-180"
    android:valueTo="0"
    android:propertyName="rotationY"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    android:duration="@integer/card_flip_time_full"/>

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

card_flip_left_out.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android" >

   <!-- Rotate. -->
   <rotate
    android:duration="@integer/card_flip_time_full"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    android:propertyName="rotationY"
    android:valueFrom="0"
    android:valueTo="180" />

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

 </set>

card_flip_right_in.xml

<!-- Before rotating, immediately set the alpha to 0. -->
<alpha
    android:duration="0"
    android:propertyName="alpha"
    android:valueFrom="1.0"
    android:valueTo="0.0" />

<!-- Rotate. -->
<rotate
    android:duration="@integer/card_flip_time_full"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    android:propertyName="rotationY"
    android:valueFrom="180"
    android:valueTo="0" />

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

card_flip_right_out.xml

   <?xml version="1.0" encoding="utf-8"?>
 <set xmlns:android="http://schemas.android.com/apk/res/android" >

<!-- Rotate. -->
<rotate
    android:duration="@integer/card_flip_time_full"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    android:propertyName="rotationY"
    android:valueFrom="0"
    android:valueTo="-180" />

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

 </set>

我更改了那些 xml 文件,但它对我们不起作用..任何人都可以解释我做错了什么。请帮助我分享使用完整教程和其他资源..任何人都可以为我提供正确的补间动画对于那些 。

4

1 回答 1

0

如果“Objacter Animation”是指 ObjectAnimator,那么兼容性库不支持它。相反,您应该看看 NineOldAndroid 库,它为旧平台带来了 Honeycomb+ 动画 API:http: //nineoldandroids.com/

于 2014-02-06T22:46:13.313 回答