旋转ImageView,旋转其它控件也可以
public class RotateImageView extends ImageView {
public RotateImageView(Context context) {
super(context);
}
public RotateImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public RotateImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
/**
* 旋转
* @param duration
* @param from
* @param to
*/
public void rotate(long duration, int from, int to){
RotateAnimation animation = new RotateAnimation(from, to ,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
animation.setDuration(duration);
animation.setFillAfter(true);
startAnimation(animation);
}
}