本文总结了作者在安卓开发过程中常用的几个动画特效,使用时将.xml文件放到res文件夹下的anim文件中。
push_left_in
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:duration="3000" android:fromXDelta="100.0%p" android:toXDelta="-110.0" /> <alpha android:duration="1000" 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" android:shareInterpolator="true" android:startOffset="2000" >
<scale android:duration="1000" android:fillAfter="false" android:fromXScale="0.0" android:fromYScale="0.0" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:pivotX="50%" android:pivotY="50%" android:repeatCount="5" android:startOffset="1000" android:toXScale="1.2" android:toYScale="1.2" />
</set>
|
透明
<?xml version="1.0" encoding="UTF-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator" android:shareInterpolator="true" android:startOffset="2000" >
<alpha android:duration="3000" android:fromAlpha="0.1" 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" android:shareInterpolator="true" android:startOffset="2000"> <translate android:fromXDelta="0" android:toXDelta="0" android:fromYDelta="200" android:toYDelta="-30" android:duration="1900" /> </set>
|
右位移
<?xml version="1.0" encoding="UTF-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator" android:shareInterpolator="true" android:startOffset="2000"> <translate android:fromXDelta="-40" android:toXDelta="40" android:fromYDelta="10" android:toYDelta="10" android:duration="2000" /> </set>
|
左位移
<?xml version="1.0" encoding="UTF-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator" android:shareInterpolator="true" android:startOffset="2000"> <translate android:fromXDelta="1" android:toXDelta="40" android:fromYDelta="10" android:toYDelta="10" android:duration="2000" /> </set>
|
旋转
<?xml version="1.0" encoding="UTF-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator" android:shareInterpolator="true" android:startOffset="2000" >
<rotate android:duration="1000" android:fromDegrees="0" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:pivotX="50%" android:pivotY="50%" android:toDegrees="+360" />
</set>
|