一、animation
RotateAnimation, ScaleAnimation, TranslateAnimation
1、RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
参数说明:角度从多少度到多少度,注意是旋转角度;
旋转的中心的确定,是相对于控件的左上角那个点的座标 加上系数
如:
RotateAnimation rotateAnimation = new RotateAnimation(
90, 360,//从旋转了90度后开始,开始转到360
Animation.RELATIVE_TO_PARENT, 2f,//相对于自己左上角座标,加上自己1倍宽
Animation.RELATIVE_TO_PARENT, 0f //相对于自己左上角座标,加上自己0倍宽
)
2、ScaleAnimation(float fromX, float toX, float fromY, float toY, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
ScaleAnimation scaleAnimation = new ScaleAnimation(
1, 0.1f, //x缩放的系数(倍数,从多少倍放到多少倍)
1, 0.1f, //y缩放的系数(倍数,从多少倍放到多少倍)
Animation.RELATIVE_TO_PARENT, 0.5f,//相对于父控件左上角座标,加上父控件的0.5倍宽
Animation.RELATIVE_TO_SELF, 0.5f); //相对于自己左上角座标,加上自己0.5倍宽
3、TranslateAnimation移动动画
TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue)
全遵循相对控件的左上角坐标 加上系数倍数后的坐标
TranslateAnimation translateAnimation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 1.0f
)
二、关于xml的声明的注意点
我引用mars老师的:如下