2011-08-22 83 views
0

我想要一个动画gif,因为这是不可能在Android中我在转换中使用单个帧。Android转换动画

除了它看起来像过渡类只会显示两个帧!我看到其他的激励方法,但他们似乎并不适用于我在做什么,还是显得老convul​​ated像一个较大婴儿Android编译

<transition xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:drawable="@drawable/activateanima"></item> 
    <item android:drawable="@drawable/activateanimb"></item> 
    <item android:drawable="@drawable/activateanimc"></item> 
    <item android:drawable="@drawable/activateanimc"></item> 
    <item android:drawable="@drawable/activateanimd"></item> 
    <item android:drawable="@drawable/activateanime"></item> 
    <item android:drawable="@drawable/activateanimf"></item> 
    <item android:drawable="@drawable/activateanimg"></item> 
</transition> 

我如何动画的图像表现得像一个动画GIF,到位。没有旋转或翻译在这里。使用android 2.1+

回答

4

您是否在Frame animation之后?请参阅:here。这将播放静止的动画。

XML文件保存在RES /动画/ rocket.xml:从上方部位

<?xml version="1.0" encoding="utf-8"?> 
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
    android:oneshot="false"> 
    <item android:drawable="@drawable/rocket_thrust1" android:duration="200" /> 
    <item android:drawable="@drawable/rocket_thrust2" android:duration="200" /> 
    <item android:drawable="@drawable/rocket_thrust3" android:duration="200" /> 
</animation-list> 

要使用:

ImageView rocketImage = (ImageView) findViewById(R.id.rocket_image); 
rocketImage.setBackgroundResource(R.drawable.rocket_thrust); 

rocketAnimation = (AnimationDrawable) rocketImage.getBackground(); 
rocketAnimation.start(); 
+0

我得到它与这种工作,种。对于我的ImageView,它必须是R.id.rocket,其中rocket是我的可绘制文件夹中的xml文件,而不是我的anim文件夹。我没有创建一个动画文件夹 – CQM

1

只需使用一个视图脚蹼之间翻转图像。只要将你的进出动画定义为0秒,并且它们应该是立即的。 (但使用alpha来确定)。视图脚蹼的好处也是自动动画和自动启动

+0

查看脚蹼更好,当然。 – CQM