首页 > 其他 > 详细

Frame动画

时间:2015-05-07 13:55:25      阅读:241      评论:0      收藏:0      [点我收藏+]

 

  • drawable目录下新建一个xml文件,内容如下:
            <?xml version="1.0" encoding="utf-8"?>
            <animation-list xmlns:android="http://schemas.android.com/apk/res/android"
                android:oneshot="true" > //onshot是指定是否循环播放
                <item
                    android:drawable="@drawable/desktop_rocket_launch_1"  //Frame动画的图片
                    android:duration="50"/> //播放这个图片持续的时间
                <item
                    android:drawable="@drawable/desktop_rocket_launch_2"
                    android:duration="100"/>
            </animation-list>

     

  • 播放Frame动画
       AnimationDrawable rocketAnimation;
       public void onCreate(Bundle savedInstanceState) {
             super.onCreate(savedInstanceState);
             setContentView(R.layout.main);
             ImageView rocketImage = (ImageView) findViewById(R.id.iv);
             rocketImage.setBackgroundResource(R.drawable.animlist); //将上边建的Frame动画的xml文件通过背景资源设置给图片
             rocketAnimation = (AnimationDrawable) rocketImage.getBackground();  //获取到图片的背景资源
        }
        public void start(View view) {
             if (!rocketAnimation.isRunning()) {
                  rocketAnimation.start();  //播放
             }
    }

     

Frame动画

原文:http://www.cnblogs.com/huangzx/p/4484366.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!