android 图片轮播动画  

/res/drawable/flag.xml

<?xml version="1.0" encoding="utf-8"?>
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/flaganim"
    android:oneshot="false"
    >
   
   
   
   
   
   
   
        


/res/layout/splash.xml
<?xml version="1.0" encoding="utf-8"?>
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" 
  android:id="@+id/TheSplashLayout"
  android:layout_gravity="center"
  >
            android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/SplashImageView"
        android:layout_gravity="center"        
        >
   
   


MainActivity.java
final ImageView splashImageView = (ImageView) findViewById(R.id.SplashImageView);
        splashImageView.setBackgroundResource(R.drawable.flag);
        final AnimationDrawable frameAnimation = (AnimationDrawable)splashImageView.getBackground();
        splashImageView.post(new Runnable(){
            @Override
            public void run() {
                frameAnimation.start();//启动动画             // frameAnimation.stop(); //关闭动画
            }            
        });  

除此之外:在AnimationDrawable中,我们还可以看到如下的几个重要方法:

setOneShot(boolean flag) 和在配置文件中进行配置一样,可以设置动画是否播放一次,false为连续播放;

addFrame (Drawable frame, int duration) 动态的添加一个图片进入该动画中

 

转载于:https://www.cnblogs.com/xubuhang/p/4223502.html

更多相关文章

  1. Android绘制圆形图片(五)
  2. Android通过内容提供器获取相册中所有图片
  3. Android(安卓)属性动画中心点无限循环
  4. Android(安卓)改变ImageView图片的Bitmap大小
  5. 一个Android实现图片的倒影效果的代码示例
  6. Android(安卓)读取Assets中图片
  7. android 按比例缩放图片(适屏)
  8. android 文字或者图片生成.pdf文件
  9. Android(安卓)二级动画弹出菜单

随机推荐

  1. linux下如何为刚安装好的Eclipse在桌面建
  2. Android ActionBar And Menu
  3. Android IntentService 与Alarm开启任务
  4. android intent activity参数传递
  5. xp jdk7环境下利用webView调用网页androi
  6. Android:Calling startActivity() from o
  7. 编写使用root权限的android应用程序
  8. [Android]长按电源键(Power Key)的处理
  9. [Linphone Android] 带视频的呼叫
  10. android通过ContentProvider实现应用间的