在android工程中新建anim文件夹
透明度控制动画效果 alpha.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android=" http://schemas.android.com/apk/res/android" >
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.1"
android:duration="3000"
/>
fromAlpha 属性为动画起始时透明度
toAlpha 属性为动画结束时透明度
0.0表示完全透明
1.0表示完全不透明
duration 属性为动画持续时间
<set xmlns:android=" http://schemas.android.com/apk/res/android" >
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.1"
android:duration="3000"
/>
fromAlpha 属性为动画起始时透明度
toAlpha 属性为动画结束时透明度
0.0表示完全透明
1.0表示完全不透明
duration 属性为动画持续时间
rotate 旋转动画效果 rotate.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android=" http://schemas.android.com/apk/res/android">
<rotate
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromDegrees="0"
android:toDegrees="+350"
android:pivotX="50%"
android:pivotY="50%"
android:duration="3000" />
<set xmlns:android=" http://schemas.android.com/apk/res/android">
<rotate
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromDegrees="0"
android:toDegrees="+350"
android:pivotX="50%"
android:pivotY="50%"
android:duration="3000" />
fromDegrees 属性为动画起始时物件的角度
toDegrees 属性为动画结束时物件旋转的角度 可以大于360度
toDegrees 属性为动画结束时物件旋转的角度 可以大于360度
尺寸伸缩动画效果 scale
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromXScale="0.0" android:toXScale="1.4" android:fromYScale="0.0"
android:toYScale="1.4" android:pivotX="50%" android:pivotY="50%"
android:fillAfter="false" android:duration="700" />
</set>
translate 位置转移动画效果
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="30"
android:toXDelta="-80"
android:fromYDelta="30"
android:toYDelta="300"
android:duration="2000"
/>
</set>