塑料机械网站建设,一个空间可以做多少个网站,wordpress文章代码插件,青岛中企动力科技股份有限公司本文由PurpleSword(jzj1993)原创#xff0c;转载请注明原文网址 http://blog.csdn.net/jzj1993常见动画有几种控件View的动画(如Dialog窗口中的圆形进度条)空间Window的动画(如DialogWindow#xff0c;PopupWindow的动画#xff0c;Activity切换时整个Window页面的动画)View… 本文由PurpleSword(jzj1993)原创转载请注明 原文网址 http://blog.csdn.net/jzj1993 常见动画有几种 控件View的动画(如Dialog窗口中的圆形进度条) 空间Window的动画(如DialogWindowPopupWindow的动画Activity切换时整个Window页面的动画) ViewGroup的LayoutAnimation动画每个子控件按照设定的顺序、延迟播放动画 动画常用anim/*.xml定义 xml中定义动画可直接使用translatescalealpharotate标签直接定义也可以放在set标签中里面定义的动画将同时开始播放。 两者都可使用AnimationUtils.loadAnimation方法加载。如果是set标签定义加载时返回的是AnimationSet实例(AnimationSet继承自Animation)。 在set标签中设置的一些属性会直接覆盖它里面定义动画的对应属性而 AnimationSet的另外一些从Animation继承的属性则无效下面是AnimationSet类的官方说明。 Represents a group of Animations that should be played together. The transformation of each individual animation are composed together into a single transform. If AnimationSet sets any properties that its children also set (for example, duration or fillBefore), the values of AnimationSet override the child values. The way that AnimationSet inherits behavior from Animation is important to understand. Some of the Animation attributes applied to AnimationSet affect the AnimationSet itself, some are pushed down to the children, and some are ignored, as follows: duration, repeatMode, fillBefore, fillAfter: These properties, when set on an AnimationSet object, will be pushed down to all child animations.repeatCount, fillEnabled: These properties are ignored for AnimationSet.startOffset, shareInterpolator: These properties apply to the AnimationSet itself. Starting with android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH, the behavior of these properties is the same in XML resources and at runtime (prior to that release, the values set in XML were ignored for AnimationSet). That is, calling setDuration(500) on an AnimationSet has the same effect as declaring android:duration500 in an XML resource for an AnimationSet object. 常规补间动画弹跳移动 Layout/activity_welcome_anim.xml 0%p表示占父组件尺寸的百分比 ?xml version1.0 encodingutf-8? set xmlns:androidhttp://schemas.android.com/apk/res/android translate android:duration500 android:fromXDelta0 android:fromYDelta0%p android:interpolatorandroid:anim/accelerate_interpolator android:toXDelta0 android:toYDelta42%p / translate android:duration350 android:fromXDelta0 android:fromYDelta0 android:interpolatorandroid:anim/decelerate_interpolator android:startOffset500 android:toXDelta0 android:toYDelta-21%p / translate android:duration350 android:fromXDelta0 android:fromYDelta0 android:interpolatorandroid:anim/accelerate_interpolator android:startOffset850 android:toXDelta0 android:toYDelta21%p / translate android:duration250 android:fromXDelta0 android:fromYDelta0 android:interpolatorandroid:anim/decelerate_interpolator android:startOffset1200 android:toXDelta0 android:toYDelta-10%p / translate android:duration250 android:fromXDelta0 android:fromYDelta0 android:interpolatorandroid:anim/accelerate_interpolator android:startOffset1450 android:toXDelta0 android:toYDelta10%p / translate android:duration150 android:fromXDelta0 android:fromYDelta0 android:interpolatorandroid:anim/decelerate_interpolator android:startOffset1700 android:toXDelta0 android:toYDelta-5%p / translate android:duration150 android:fromXDelta0 android:fromYDelta0 android:interpolatorandroid:anim/accelerate_interpolator android:startOffset1850 android:toXDelta0 android:toYDelta5%p / /set 再例如常规补间动画缩放、透明度 ?xml version1.0 encodingutf-8? set xmlns:androidhttp://schemas.android.com/apk/res/android scale android:duration800 android:fromXScale0.0 android:fromYScale0.0 android:pivotX50% android:pivotY50% android:toXScale1.0 android:toYScale1.0 / alpha android:duration800 android:fromAlpha0.0 android:toAlpha1.0 / /set 再如上浮效果移动、透明度 ?xml version1.0 encodingutf-8? set xmlns:androidhttp://schemas.android.com/apk/res/android android:interpolatorandroid:anim/linear_interpolator translate android:duration500 android:fromXDelta0 android:fromYDelta5% android:toXDelta0 android:toYDelta0% / alpha android:duration500 android:fromAlpha0.0 android:toAlpha1.0 / alpha android:duration100 android:fromAlpha1.0 android:startOffset1400 android:toAlpha1.0 / /set 可使用Java程序加载 this.setContentView(R.layout.activity_welcome); anim AnimationUtils.loadAnimation(this, R.anim.welcome_anim); // 动画效果执行完毕后,View对象保留在终止的位置 anim.setFillEnabled(true); anim.setFillAfter(true); this.findViewById(R.id.point).setAnimation(anim); 还可设置动画监听器 anim.setAnimationListener(listener); /** * 动画监听器 */ private AnimationListener listener new AnimationListener() { Override public void onAnimationEnd(Animation animation) { // startMain(); } Override public void onAnimationStart(Animation animation) { } Override public void onAnimationRepeat(Animation animation) { } }; 在Dialog中动画的加载 LayoutInflater inflater LayoutInflater.from(context); View v inflater.inflate(R.layout.dialog_voice, null); ImageView img (ImageView) v.findViewById(R.id.dialog_img); Animation anim AnimationUtils.loadAnimation(context, R.anim.center_rotate_repeat); img.startAnimation(anim); new AlertDialog.Builder(context).setView(v); 给整个Dialog设置动画 dialog.getWindow().setWindowAnimations(R.style.quick_scale_anim); 给PopupWindow设置动画 pop.setAnimationStyle(R.style.quick_scale_anim); Activity的切换动画 代码实现Activity切换动画 startActivity(new Intent(this, ListAlarm.class)); overridePendingTransition(R.anim.anim_activity_in, R.anim.anim_activity_unchange); 或者 ActivityGuide.this.finish(); overridePendingTransition(R.anim.alpha_stay, R.anim.alpha_exit); 在XML中定义Activity切换动画 Activity切换动画不能设置SingleInstance属性会导致动画失效 style nameactivityAnimation parentandroid:style/Animation item nameandroid:windowEnterAnimationnull/item item nameandroid:windowExitAnimationnull/item !-- 新的Activity启动时Enter动画 -- item nameandroid:activityOpenEnterAnimationanim/slide_left_in/item !-- 新的Activity启动时原有Activity的Exit动画 -- item nameandroid:activityOpenExitAnimationanim/keep/item !-- 新的Activity退出时原有ActivityEnter动画 -- item nameandroid:activityCloseEnterAnimationanim/keep/item !-- 新的Activity退出时Exit动画 -- item nameandroid:activityCloseExitAnimationanim/slide_right_out/item /style Manifest.xml application android:themestyle/app_theme activity android:name.ui.ActivityWelcome android:themestyle/app_theme_fullscreen /activity /application style.xml style nameapp_theme parentandroid:style/Theme.Light.NoTitleBar item nameandroid:windowAnimationStylestyle/activity_anim/item /style style nameactivity_anim item nameandroid:windowEnterAnimationanim/quick_alpha_enter/item item nameandroid:windowExitAnimationanim/quick_alpha_stay/item /style anim/quick_alpha_enter.xml anim/quick_alpha_stay.xml LayoutAnimation 1、在 layout_anim_item.xml 中定义子View动画 2、在 layout_anim.xml 中定义Layout动画并引用子View动画 layoutAnimation xmlns:androidhttp://schemas.android.com/apk/res/android android:animationanim/layout_anim_item android:animationOrdernormal android:delay0.25 / 3、在ViewGroup中引用自定义Layout动画 ViewGroup android:layoutAnimationanim/layout_anim 近期自己搭建了一个网站以后我的博客会转移到个人网站欢迎大家关注~ 网址是http://purplesword.info