我正在尝试在 4 个 png 图像上执行动画。我在drawable
文件夹中有文件res
夹,其中包含要制作动画的图像和一个animation.xml
现在我的问题是:当我说animation.start
我在模拟器上看不到任何东西时
我的代码:
package com.androcles.TreeActivity;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.widget.ImageView;
public class TreeActivity extends Activity {
private ImageView image1;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tree);
image1 = (ImageView)findViewById(R.id.imageView1);
image1.setImageBitmap(null);
image1.setBackgroundResource(R.drawable.animation);
final AnimationDrawable mailAnimation = (AnimationDrawable) image1.getBackground();
image1.post(new Runnable() {
public void run()
{
if ( mailAnimation != null )
{
System.out.println("Before Animation Starts...!!!!!");
mailAnimation.start();
System.out.println("After Animation Starts...!!!!!");
}
}
});
}
}