Android--Animation

一、animation

                   RotateAnimation, ScaleAnimation, TranslateAnimation

1RotateAnimation(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倍宽

)

2ScaleAnimation(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倍宽

3TranslateAnimation移动动画

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老师的:如下

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值