0

我正在尝试在 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...!!!!!");
        }
    }
});
}
 }
4

2 回答 2

0

试试这些代码。

View view;
 view=(Button)findViewById(R.id.continue_but);    // may be image or some thing 


   Animation hyperspaceJump = AnimationUtils.loadAnimation(AppActivity.this, R.anim.slide_left); 
         view.startAnimation(hyperspaceJump); 
         view.setVisibility(View.VISIBLE);
于 2013-01-04T09:47:22.447 回答
0

试试这个方法:

 m_animation = AnimationUtils.loadAnimation(
                    getApplicationContext(), R.anim.alpha_animation);
            m_ivImage.startAnimation(m_animation);
于 2013-01-04T07:53:36.717 回答