实现播放图片功能,单张图片可加动画

实现播放图片功能,单张图片可加动画数组


Animation:ide


首先,建立一个数组来存放图片,:动画

        int[] imgs = { R.drawable.a, R.drawable.b, R.drawable.c, R.drawable.d,R.drawable.espa

};.net

          实例化ImageView    ,用数组中的图片替换ImageView中的图片图片

                    imageView1.setImageResource(imgs[i]);
animation

        建立Animation单张图片动画
it

    

        AlphaAnimation myAnimation_Alpha;io

ScaleAnimation myAnimation_Scale;class

                myAnimation_Alpha = new AlphaAnimation(1f, 0f);

myAnimation_Alpha.setDuration(3000);

// 缩放

myAnimation_Scale = new ScaleAnimation(1f, 1.4f, 1f, 1.4f,

Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,

0.5f);

myAnimation_Scale.setDuration(3000);


建立AnimationSet来放Anrmation动画集合

    AnimationSet animation;

                animation.addAnimation(myAnimation_Scale);

animation.addAnimation(myAnimation_Alpha);

启动Animation动画

            imageView1.setAnimation(animation);

判断动画是否执行完毕   实现方法

                animation.setAnimationListener(new AnimationListener() {


@Override

public void onAnimationStart(Animation animation) {

// TODO Auto-generated method stub


}


@Override

public void onAnimationRepeat(Animation animation) {

// TODO Auto-generated method stub


}


                            //若是动画执行完毕,再次调用自身方法实现循环

@Override

public void onAnimationEnd(Animation animation) {

init();

}

});

如需看所有Demo    请到http://download.csdn.net/detail/qq_26470369/8748803下载

相关文章
相关标签/搜索