<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/g1"
android:duration="200" />
<item android:drawable="@drawable/g2"
android:duration="200" />
<item android:drawable="@drawable/g3" 、
android:duration="200" />
</animation-list>
ImageView iv = (ImageView) findViewById(R.id.iv);
//把动画文件设置为imageView的背景
iv.setBackgroundResource(R.drawable.animations);
AnimationDrawable ad = (AnimationDrawable)
iv.getBackground();
//播放动画
ad.start();
//创建为位移动画对象,设置动画的初始位置和结束位置 TranslateAnimation ta = new TranslateAnimation(10, 150, 20, 140);
TranslateAnimation ta = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 2, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 2);
//设置动画持续时间
ta.setDuration(2000);
//动画重复播放的次数
ta.setRepeatCount(1);
//动画重复播放的模式
ta.setRepeatMode(Animation.REVERSE);
//动画播放完毕后,组件停留在动画结束的位置上
ta.setFillAfter(true);
//播放动画
iv.startAnimation(ta);
ScaleAnimation sa = new ScaleAnimation(0.1f, 4, 0.1f, 4);
ScaleAnimation sa = new ScaleAnimation(0.1f, 4, 0.1f, 4, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
AlphaAnimation aa = new AlphaAnimation(0, 0.5f);
RotateAnimation ra = new RotateAnimation(20, 360);
RotateAnimation ra = new RotateAnimation(20, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
//创建动画集合
AnimationSet set = new AnimationSet(false);
//往集合中添加动画
set.addAnimation(aa);
set.addAnimation(sa);
set.addAnimation(ra);
iv.startAnimation(set);
//具有get、set方法的成员变量就称为属性 ObjectAnimator oa = ObjectAnimator.ofFloat(bt, "translationX", 0, 100) ;
ObjectAnimator oa = ObjectAnimator.ofFloat(bt, "scaleY", 0.1f, 2);
ObjectAnimator oa = ObjectAnimator.ofFloat(bt, "alpha", 0.1f, 1);
ObjectAnimator oa = ObjectAnimator.ofFloat(bt, "rotation", 20, 270);
ObjectAnimator oa = ObjectAnimator.ofFloat(bt, "rotationY", 20, 180);
ObjectAnimator oa = ObjectAnimator.ofFloat(bt, "translationX", 0, 70, 30, 100) ;
//创建动画师集合
AnimatorSet set = new AnimatorSet();
//设置要播放动画的组件
set.setTarget(bt);
//所有动画有先后顺序的播放
//set.playSequentially(oa, oa2, oa3, oa4);
//所有动画一起播放
set.playTogether(oa, oa2, oa3, oa4);
set.start();
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有