11.Android anim drawable color 技巧
Anim Set属性
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Set 属性
shareInterpolator true时,interpolator应用到所有子元素中。
-->
<!--
公共属性
detachWallpaper 是否在壁纸上运行,设置了壁纸背景的窗口动画(window animation)才有效。
设为true,则动画只在窗口运行,壁纸背景保持不变。
fillEnabled true时,fillBefore的值才有效,否则fillBefore会被忽略。
fillBefore true时,动画执行完后,View会还原动画执行前的初始状态;否则不会,默认即为true。
repeatCount 动画重复执行的次数,默认为0,不重复;-1或infinite,无限重复。
repeatMode 动画重复执行的模式,默认restart 动画重复执行时从起点开始;reverse 动画会反方向执行。
startOffset 动画执行之前的等待时间,毫秒为单位;重复执行时,每次执行前同样执行等待时间。
zAdjustment 动画的内容在动画运行时在z轴上的位置:
normal 默认值,在z轴上
top 在z轴最上层
bottom 在z轴最下层
interpolator 动画速率的变化
-->
<!--
alpha 渐变动画
对应的 AlphaAnimation
AlphaAnimation alpha = (AlphaAnimation) AnimationUtils.loadAnimation(this, R.anim.alpha);
view.startAnimation(alpha);
duration 动画持续时间
fromAlpha 动画开始时透明度,默认值1.0,最小值0.0
toAlpha 动画结束时透明度,默认值1.0,最小值0.0
-->
<alpha
android:duration="500"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
<!--
scale 缩放动画
对应的 ScaleAnimation
ScaleAnimation scale = (ScaleAnimation) AnimationUtils.loadAnimation(this, R.anim.scale);
view.startAnimation(scale);
duration 动画持续时间
fromXScale 动画开始时,x轴上(宽度)的缩放比例。0.0为没有大小,1.0为正常大小,大于1.0为放大,小于1.0为缩小。
fromYScale 动画开始时,y轴上(高度)的缩放比例。0.0为没有大小,1.0为正常大小,大于1.0为放大,小于1.0为缩小。
toXScale 动画结束时,x轴上(宽度)的缩放比例。0.0为没有大小,1.0为正常大小,大于1.0为放大,小于1.0为缩小。
toYScale 动画结束时,y轴上(高度)的缩放比例。0.0为没有大小,1.0为正常大小,大于1.0为放大,小于1.0为缩小。
pivotX 缩放时的固定不变的x坐标,0%为最左边,100%为最右边。
pivotY 缩放时的固定不变的y坐标,0%为最顶部,100%为最底部。
-->
<scale
android:duration="500"
android:fromXScale="0.0"
android:fromYScale="0.0"
android:pivotX="0%"
android:pivotY="100%"
android:toXScale="1.0"
android:toYScale="1.0" />
<!--
translate 平移动画
对应的 TranslateAnimation
TranslateAnimation translate = (TranslateAnimation) AnimationUtils.loadAnimation(this, R.anim.translate);
view.startAnimation(translate);
duration 动画持续时间
fromXDelta 起始位置的X坐标的偏移量
fromYDelta 结束位置的X坐标的偏移量
toXDelta 起始位置的Y坐标的偏移量
toYDelta 结束位置的Y坐标的偏移量
1.-100到100,以"%"结束,表示相对于View本身的百分比位置;-100%表示控件左边或者上边,100%表示控件右边或者下边
2.以"%p"(parent)结束,表示相对于View的父View的百分比位置;
3.没有任何后缀,表示相对于View本身具体的像素值
-->
<translate
android:duration="500"
android:fromXDelta="100%"
android:fromYDelta="-100%"
android:toXDelta="-100%"
android:toYDelta="100%" />
<!--
rotate 旋转动画
对应的 RotateAnimation
RotateAnimation rotate = (RotateAnimation) AnimationUtils.loadAnimation(this, R.anim.rotate);
view.startAnimation(rotate);
duration 动画持续时间
fromDegrees 旋转开始的角度
toDegrees 旋转结束的角度
pivotX 旋转中心点的X坐标,纯数字表示相对于View本身左边缘的像素偏移量;
带"%"后缀时表示相对于View本身左边缘的百分比偏移量;带"%p"后缀时表示相对于父View左边缘的百分比偏移量
pivotY 旋转中心点的Y坐标,纯数字表示相对于View本身顶部边缘的像素偏移量;
带"%"后缀时表示相对于View本身顶部边缘的百分比偏移量;带"%p"后缀时表示相对于父View顶部边缘的百分比偏移量
-->
<rotate
android:duration="500"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" />
</set>
Animi interpolator
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--
加速度设置
<动画标签
android:interpolator="@资源id"/>
-->
<!--
对应的类 AccelerateDecelerateInterpolator
对应的资源 @android:anim/accelerate_decelerate_interpolator
作用 动画开始与结束时速率改变比较慢,在中间时加速
-->
<accelerateDecelerateInterpolator />
<!--
对应的类 AccelerateInterpolator
对应的资源 @android:anim/accelerate_interpolator
作用 动画开始时速率改变比较慢,然后开始加速
factor 加速速率,默认值1.0。
-->
<accelerateInterpolator android:factor="1" />
<!--
对应的