先简单写出各个标签对应的类,方便大家理解: scale —— ScaleAnimation alpha —— AlphaAnimation rotate —— RotateAnimation translate...这是alpha标签对就的类,官方SDK文档地址是: 《AlphaAnimation》 同样alpha标签自有的属性有: android:fromAlpha 动画开始的透明度,从0.0 –1.0...,0.0表示全透明,1.0表示完全不透明 android:toAlpha 动画结束时的透明度,也是从0.0 –1.0 ,0.0表示全透明,1.0表示完全不透明 所对应的构造函数为: AlphaAnimation...(Context context, AttributeSet attrs) 同样,从本地XML加载动画,基本不用 AlphaAnimation(float fromAlpha, float toAlpha...” android:pivotY=“50%”/> 对应的JAVA代码为: [java] view plain copy alphaAnim = new AlphaAnimation
alphaAnimation = new AlphaAnimation(1.0f,0.0f); //设置动画的时间长度 alphaAnimation.setDuration...透明动画 //AlphaAnimation 透明动画 //第一个参数是开始的透明度,第二个参数是结束的透明度,1.0完全透明,0.0完全透明 AlphaAnimation alphaAnimation...= new AlphaAnimation(1.0f, 0.0f); //设置动画的时间长度 alphaAnimation.setDuration(2000); //设置重复的类型 alphaAnimation.setRepeatMode...= new AlphaAnimation(1.0f, 0.0f); alphaAnimation.setDuration(2000); alphaAnimation.setRepeatMode(Animation.REVERSE...alphaAnimation = new AlphaAnimation(1.0f, 0.0f); alphaAnimation.setDuration(2000); alphaAnimation.setRepeatMode
说到淡入淡出动画,可能大家会想到补间动画里面的AlphaAnimation,不过这个深浅动画只能对透明度做渐变效果,也就是只能对一个图形做深浅的颜色变换。...如果我们想要从A图片逐渐变为B图片,也就是要实现淡入淡出(Fade-in and Fade-out)效果时,AlphaAnimation显然就不够用了。...下面代码同时实现了AlphaAnimation和TransitionDrawable的使用,方便大家对比这两种动画效果。...alphaAnimation; private TransitionDrawable transitionDrawable; @Override protected void onCreate...= new AlphaAnimation(0.0f, 1.0f); alphaAnimation.setDuration(3000); //深浅动画持续时间 alphaAnimation.setFillAfter
说到淡入淡出动画,首先想到补间动画里面的AlphaAnimation,不过这个深浅动画只能对透明度做渐变效果,也就是只能对一个图形做深浅的颜色变换。...; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.AlphaAnimation...alphaAnimation; private TransitionDrawable transitionDrawable; @Override protected void...= new AlphaAnimation(0.0f, 1.0f); alphaAnimation.setDuration(3000); //深浅动画持续时间 alphaAnimation.setFillAfter...); alphaAnimation.start(); } else if (v.getId() == R.id.btn_play2) {
setContentView(R.layout.activity_welcome); welcomeImage=(ImageView) this.findViewById(R.id.welcome); AlphaAnimation...alphaAnimation=new AlphaAnimation(0.1f, 1.0f);////定义一个具有淡入效果的对象 alphaAnimation.setDuration(3000)...;//定义闪屏时间(毫秒) welcomeImage.startAnimation(alphaAnimation); alphaAnimation.setAnimationListener...setContentView(R.layout.activity_welcome); welcomeImage=(ImageView) this.findViewById(R.id.welcome); AlphaAnimation...alphaAnimation=new AlphaAnimation(0.1f,1.0f);////定义1个具有淡入效果的对象 welcomeImage.startAnimation(alphaAnimation
mInUp = createAnim(true, true); AnimationSet animationSet = new AnimationSet(true); AlphaAnimation...alphaAnimation = new AlphaAnimation(0,1); animationSet.addAnimation(alphaAnimation);...mOutUp = createAnim(false, true); AnimationSet animationSet = new AnimationSet(true); AlphaAnimation...alphaAnimation = new AlphaAnimation(1,0); animationSet.addAnimation(alphaAnimation);
alphaAnimation = new AlphaAnimation(1.0f, 0.5f); scaleAnimation.setDuration(800); scaleAnimation.setRepeatCount...(Animation.INFINITE); alphaAnimation.setRepeatCount(Animation.INFINITE); as.setDuration(800); as.addAnimation...(scaleAnimation); as.addAnimation(alphaAnimation); iv1.startAnimation(as); } private void setAnim2...alphaAnimation = new AlphaAnimation(0.5f, 0.1f); scaleAnimation.setDuration(800); scaleAnimation.setRepeatCount...(scaleAnimation); as.addAnimation(alphaAnimation); iv2.startAnimation(as); } 接下来就是第二种自定义动画实现 首先定义
alphaAnimation = new AlphaAnimation(1.0f, 0.5f); scaleAnimation.setDuration(800); scaleAnimation.setRepeatCount...(Animation.INFINITE); alphaAnimation.setRepeatCount(Animation.INFINITE); as.setDuration(800); as.addAnimation...(scaleAnimation); as.addAnimation(alphaAnimation); iv1.startAnimation(as); } 最外层imageView的动画 private...alphaAnimation = new AlphaAnimation(0.5f, 0.1f); scaleAnimation.setDuration(800); scaleAnimation.setRepeatCount...(scaleAnimation); as.addAnimation(alphaAnimation); iv2.startAnimation(as); } 效果图 ?
@param duration 执行时间 */ public static void fadeOut(final View view,long duration){ AlphaAnimation...alphaAnimation=new AlphaAnimation(1, 0); alphaAnimation.setDuration(duration); view.startAnimation...(alphaAnimation); //监听动画结束,删除View元素 alphaAnimation.setAnimationListener(new AnimationListener...alphaAnimation=new AlphaAnimation(0, 1); //设置开始时间延迟 alphaAnimation.setStartOffset(delay...); alphaAnimation.setDuration(duration); view.startAnimation(alphaAnimation); } }
简单一点的,如AlphaAnimation。直接定义,然后设置属性,然后startAnimation 复杂一点的,可以用AnimationSet。...如下: AnimationSet animationSet = new AnimationSet(false); AlphaAnimation...alphaAnimation = new AlphaAnimation(1.0f, 0.1f); alphaAnimation.setDuration(3000);...0.5f); rotateAnimation.setDuration(3000); animationSet.addAnimation(alphaAnimation
= [CABasicAnimation animationWithKeyPath:@"bounds"]; alphaAnimation1.duration = 0.1; alphaAnimation1...:@"transform.scale"]; alphaAnimation.duration = self.animationDuration; alphaAnimation.fromValue...= [NSNumber numberWithFloat:1.0]; alphaAnimation.toValue = [NSNumber numberWithFloat:0.1]; alphaAnimation.timingFunction...= [CABasicAnimation animationWithKeyPath:@"bounds"]; alphaAnimation1.duration = 0.1; alphaAnimation1...(0, 0, endView.bounds.size.width, endView.bounds.size.height)]; alphaAnimation1.timingFunction =
对象,从完全不透明到完全透明 42 AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.0f); 43...// 设置动画持续时间为2秒钟 44 alphaAnimation.setDuration(2000); 45 // 执行动画前,延迟0.5...对象,从完全透明到完全不透明 74 AlphaAnimation alphaAnimation = new AlphaAnimation(0.0f, 1.0f); 75...// 设置动画持续时间为2秒钟 76 alphaAnimation.setDuration(2000); 77 // 执行动画前,延迟0.5...秒钟 78 alphaAnimation.setStartOffset(500); 79 viewGroup.addView(imageView
方法是异步的在一个单独的线程里面执行的,因此,有时候,下面的代码是播放不了的,建议放在按钮点击事件里,或者屏幕触摸事件里 调用AnimationDrawable对象start()方法,开始播放 tween动画 透明度 获取AlphaAnimation...对象,new AlphaAnimation(),参数:从0.0f透明度,到1.0f透明度 AlphaAnimation对象的setDuration()方法,设置执行时间 调用View对象的startAnimation...()方法,参数:AlphaAnimation对象 缩放 获取ScaleAnimation对象,new ScaleAnimation(),参数: 原始宽,变化后宽,原始高,变化后高,Animation.RELATIVE_TO_SELF
rotate XML配置文件中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面转移旋转动画效果 Java Code代码中 AlphaAnimation...AlphaAnimation AlphaAnimation类对象定义 private AlphaAnimation myAnimation_Alpha; AlphaAnimation类对象构造 AlphaAnimation...alphaAnimation = new AlphaAnimation(0.2f, 1.0f); ScaleAnimation scaleAnimation = new ScaleAnimation(...1, 1.1f, 1, 1.1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); alphaAnimation.setDuration...(3000); scaleAnimation.setDuration(3000); animationSet.addAnimation(alphaAnimation); animationSet.addAnimation
集合动画AnimationSet 补间动画有四大类:透明度动画AlphaAnimation、旋转动画RotateAnimation、缩放动画ScaleAnimation、平移动画TranslateAnimation...= new AlphaAnimation(1.0f, 0.1f); alphaAnimation.setDuration(3000); alphaAnimation.setFillAfter(...= new AlphaAnimation(0.1f, 1.0f); alphaAnimation2.setDuration(3000); alphaAnimation2.setFillAfter...= new AlphaAnimation(1.0f, 0.1f); alphaAnimation.setDuration(3000); alphaAnimation.setFillAfter(...= new AlphaAnimation(0.1f, 1.0f); alphaAnimation2.setDuration(3000); alphaAnimation2.setFillAfter
补间动画(Tween)和帧动画(Frame) 补间动画主要有以下几种: 旋转(RotateAnimation) 平移(TranslateAnimation) 拉伸(ScaleAnimation) 透明度(AlphaAnimation...alphaAnimation = new AlphaAnimation(1, // 0.5f);//1能自动转换为float,0.5默认为double值 AlphaAnimation alphaAnimation...= new AlphaAnimation(1, 0); // 设置执行时间,默认为0 alphaAnimation.setDuration(3000); // 重复次数 alphaAnimation.setRepeatCount...(3); // 重复模式,Animation.RESTART:从头开始,Animation.REVERSE:逆序 alphaAnimation.setRepeatMode(Animation.REVERSE...alphaAnimation1 = AnimationUtils.loadAnimation(this, R.anim.alpha_anim); tv.startAnimation(alphaAnimation1
Animation 的子类 2 动画可以按先后顺序执行 支持背景色的修改 Animator 的子类 AnimationSet的使用 微卡智享 一般来我说我们在App中常用的都是一些视图动画:包括透明动画(AlphaAnimation...则代表使用自定义interpolator AnimationSet animationSet=new AnimationSet(false); //透明度从0至1 AlphaAnimation...alphaAnimation = new AlphaAnimation(0, 1); //旋转两圈 RotateAnimation rotateAnimation=new...(1); translateAnimation.setRepeatMode(Animation.REVERSE); animationSet.addAnimation(alphaAnimation
由四种类型组成 XML中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面转移旋转动画效果 JavaCode中 AlphaAnimation...RotateAnimation 画面转移旋转动画效果 Android动画模式 Animation主要有两种动画模式: 一种是tweened animation(渐变动画) XML中 JavaCode alpha AlphaAnimation...Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF, 0.5f); Android动画解析–JavaCode AlphaAnimation...① AlphaAnimation类对象定义 1. private AlphaAnimation myAnimation_Alpha; ② AlphaAnimation类对象构造 //AlphaAnimation...myAnimation_Alpha.setDuration(5000); //设置时间持续时间为 5000毫秒 ScaleAnimation ① ScaleAnimation类对象定义 private AlphaAnimation
渐变动画 AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1); alphaAnimation.setDuration...(1000); alphaAnimation.setFillAfter(true); //4....rotateAnimation); animationSet.addAnimation(scaleAnimation); animationSet.addAnimation(alphaAnimation
正好对应之前我们在XML中学到的5中动画的属性,如下: XML 实体类 scale ScaleAnimation alpha AlphaAnimation rotate RotateAnimation...color=#006400 >构造函数: AlphaAnimation(Context context, AttributeSet...alphaAnimation = new AlphaAnimation(1.0f, 0.5f); alphaAnimation.setDuration(3000); alphaAnimation.setRepeatCount...(2); alphaAnimation.setRepeatMode(Animation.REVERSE); alphaAnimation.setFillAfter(true); mTextView.setAnimation...(alphaAnimation); 效果与之前是一样的。
领取专属 10元无门槛券
手把手带您无忧上云