use of android.view.animation.RotateAnimation in project JustAndroid by chinaltz.
the class AbAnimationUtil method playRotateAnimation.
/**
* 旋转动画
* @param v
* @param durationMillis
* @param repeatCount Animation.INFINITE
* @param repeatMode Animation.RESTART
*/
public static void playRotateAnimation(View v, long durationMillis, int repeatCount, int repeatMode) {
// 创建AnimationSet对象
AnimationSet animationSet = new AnimationSet(true);
// 创建RotateAnimation对象
RotateAnimation rotateAnimation = new RotateAnimation(0f, +360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
// 设置动画持续
rotateAnimation.setDuration(durationMillis);
rotateAnimation.setRepeatCount(repeatCount);
// Animation.RESTART
rotateAnimation.setRepeatMode(repeatMode);
// 动画插入器
rotateAnimation.setInterpolator(v.getContext(), android.R.anim.decelerate_interpolator);
// 添加到AnimationSet
animationSet.addAnimation(rotateAnimation);
// 开始动画
v.startAnimation(animationSet);
}
use of android.view.animation.RotateAnimation in project smartmodule by carozhu.
the class OptAnimationLoader method createAnimationFromXml.
private static Animation createAnimationFromXml(Context c, XmlPullParser parser, AnimationSet parent, AttributeSet attrs) throws XmlPullParserException, IOException {
Animation anim = null;
// Make sure we are on a start tag.
int type;
int depth = parser.getDepth();
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
if (type != XmlPullParser.START_TAG) {
continue;
}
String name = parser.getName();
if (name.equals("set")) {
anim = new AnimationSet(c, attrs);
createAnimationFromXml(c, parser, (AnimationSet) anim, attrs);
} else if (name.equals("alpha")) {
anim = new AlphaAnimation(c, attrs);
} else if (name.equals("scale")) {
anim = new ScaleAnimation(c, attrs);
} else if (name.equals("rotate")) {
anim = new RotateAnimation(c, attrs);
} else if (name.equals("translate")) {
anim = new TranslateAnimation(c, attrs);
} else {
try {
anim = (Animation) Class.forName(name).getConstructor(Context.class, AttributeSet.class).newInstance(c, attrs);
} catch (Exception te) {
throw new RuntimeException("Unknown animation name: " + parser.getName() + " error:" + te.getMessage());
}
}
if (parent != null) {
parent.addAnimation(anim);
}
}
return anim;
}
use of android.view.animation.RotateAnimation in project smartmodule by carozhu.
the class AnimationController method rotateIn.
public void rotateIn(View view, long durationMillis, long delayMillis) {
RotateAnimation animation = new RotateAnimation(-90, 0, rela1, 0, rela1, 1);
baseIn(view, animation, durationMillis, delayMillis);
}
use of android.view.animation.RotateAnimation in project smartmodule by carozhu.
the class AnimationController method rotateOut.
public void rotateOut(View view, long durationMillis, long delayMillis) {
RotateAnimation animation = new RotateAnimation(0, 90, rela1, 0, rela1, 1);
baseOut(view, animation, durationMillis, delayMillis);
}
use of android.view.animation.RotateAnimation in project JustAndroid by chinaltz.
the class OptAnimationLoader method createAnimationFromXml.
private static Animation createAnimationFromXml(Context c, XmlPullParser parser, AnimationSet parent, AttributeSet attrs) throws XmlPullParserException, IOException {
Animation anim = null;
// Make sure we are on a start tag.
int type;
int depth = parser.getDepth();
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
if (type != XmlPullParser.START_TAG) {
continue;
}
String name = parser.getName();
if (name.equals("set")) {
anim = new AnimationSet(c, attrs);
createAnimationFromXml(c, parser, (AnimationSet) anim, attrs);
} else if (name.equals("alpha")) {
anim = new AlphaAnimation(c, attrs);
} else if (name.equals("scale")) {
anim = new ScaleAnimation(c, attrs);
} else if (name.equals("rotate")) {
anim = new RotateAnimation(c, attrs);
} else if (name.equals("translate")) {
anim = new TranslateAnimation(c, attrs);
} else {
try {
anim = (Animation) Class.forName(name).getConstructor(Context.class, AttributeSet.class).newInstance(c, attrs);
} catch (Exception te) {
throw new RuntimeException("Unknown animation name: " + parser.getName() + " error:" + te.getMessage());
}
}
if (parent != null) {
parent.addAnimation(anim);
}
}
return anim;
}
Aggregations