标签:des android style blog http color os io 使用
控件View的动画(如Dialog窗口中的圆形进度条)空间Window的动画(如DialogWindow,PopupWindow的动画,Activity切换时整个Window页面的动画)ViewGroup的LayoutAnimation动画,每个子控件按照设定的顺序、延迟播放动画
xml中定义动画,可直接使用<translate><scale><alpha><rotate>标签直接定义,也可以放在<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:
Starting withandroid.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, callingsetDuration(500)
on an AnimationSet has the same effect as declaringandroid:duration="500"
in an XML resource for an AnimationSet object.
常规补间动画:弹跳(移动)
Layout/activity_welcome_anim.xml(0%p表示占父组件尺寸的百分比)
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" ><translateandroid:duration="500"android:fromXDelta="0"android:fromYDelta="0%p"android:interpolator="@android:anim/accelerate_interpolator"android:toXDelta="0"android:toYDelta="42%p" /><translateandroid:duration="350"android:fromXDelta="0"android:fromYDelta="0"android:interpolator="@android:anim/decelerate_interpolator"android:startOffset="500"android:toXDelta="0"android:toYDelta="-21%p" /><translateandroid:duration="350"android:fromXDelta="0"android:fromYDelta="0"android:interpolator="@android:anim/accelerate_interpolator"android:startOffset="850"android:toXDelta="0"android:toYDelta="21%p" /><translateandroid:duration="250"android:fromXDelta="0"android:fromYDelta="0"android:interpolator="@android:anim/decelerate_interpolator"android:startOffset="1200"android:toXDelta="0"android:toYDelta="-10%p" /><translateandroid:duration="250"android:fromXDelta="0"android:fromYDelta="0"android:interpolator="@android:anim/accelerate_interpolator"android:startOffset="1450"android:toXDelta="0"android:toYDelta="10%p" /><translateandroid:duration="150"android:fromXDelta="0"android:fromYDelta="0"android:interpolator="@android:anim/decelerate_interpolator"android:startOffset="1700"android:toXDelta="0"android:toYDelta="-5%p" /><translateandroid:duration="150"android:fromXDelta="0"android:fromYDelta="0"android:interpolator="@android:anim/accelerate_interpolator"android:startOffset="1850"android:toXDelta="0"android:toYDelta="5%p" /></set>
可使用Java程序加载
再例如常规补间动画:缩放、透明度
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" ><scaleandroid:duration="800"android:fromXScale="0.0"android:fromYScale="0.0"android:pivotX="50%"android:pivotY="50%"android:toXScale="1.0"android:toYScale="1.0" /><alphaandroid:duration="800"android:fromAlpha="0.0"android:toAlpha="1.0" /></set>
再如上浮效果(移动、透明度)
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"android:interpolator="@android:anim/linear_interpolator" ><translateandroid:duration="500"android:fromXDelta="0"android:fromYDelta="5%"android:toXDelta="0"android:toYDelta="0%" /><alphaandroid:duration="500"android:fromAlpha="0.0"android:toAlpha="1.0" /><alphaandroid:duration="100"android:fromAlpha="1.0"android:startOffset="1400"android:toAlpha="1.0" /></set>
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);
Manifest.xml<applicationandroid:theme="@style/app_theme" ><activityandroid:name=".ui.ActivityWelcome"android:theme="@style/app_theme_fullscreen" ></activity></application>
style.xml<style name="app_theme" parent="@android:style/Theme.Light.NoTitleBar"><item name="android:windowAnimationStyle">@style/activity_anim</item></style>
<style name="activity_anim"><item name="android:windowEnterAnimation">@anim/quick_alpha_enter</item><item name="android:windowExitAnimation">@anim/quick_alpha_stay</item></style>
anim/quick_alpha_enter.xml
anim/quick_alpha_stay.xml
1、在 layout_anim_item.xml 中定义子View动画
2、在 layout_anim.xml 中定义Layout动画,并引用子View动画
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"android:animation="@anim/layout_anim_item"android:animationOrder="normal"android:delay="0.25" />
3、在ViewGroup中引用自定义Layout动画<ViewGroupandroid:layoutAnimation="@anim/layout_anim" >
安卓动画知识总结 Animation AnimationSet LayoutAnimation
标签:des android style blog http color os io 使用
原文地址:http://blog.csdn.net/jzj1993/article/details/39059489