android 图片轮播动画  

android 多张图片动画方式轮播(转载)_第1张图片

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

随机推荐

  1. Android实现九宫格
  2. Android(安卓)Socket开发 注意事项
  3. android:showAsAction="never"是做什么用的
  4. Android(安卓)wakeLock 分析
  5. xmlns:android="http://schemas.android.
  6. Android(安卓)移动端网络优化 (四)
  7. Android(安卓)中的消息传递,详解广播机制
  8. Android系统权限和root权限
  9. Android入门篇
  10. Android(安卓)源码修改按键长按响应间隔