Example usage for android.view.animation RotateAnimation RotateAnimation

List of usage examples for android.view.animation RotateAnimation RotateAnimation

Introduction

In this page you can find the example usage for android.view.animation RotateAnimation RotateAnimation.

Prototype

public RotateAnimation(float fromDegrees, float toDegrees) 

Source Link

Document

Constructor to use when building a RotateAnimation from code.

Usage

From source file:Main.java

@SuppressWarnings("IfCanBeSwitch")
private static Animation createAnimationFromXml(Context c, XmlPullParser parser, AnimationSet parent,
        AttributeSet attrs) throws XmlPullParserException, IOException {

    Animation anim = null;//w  w  w  . j  av a2 s .c o m

    // 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 {
            throw new RuntimeException("Unknown animation name: " + parser.getName());
        }

        if (parent != null) {
            parent.addAnimation(anim);
        }
    }

    return anim;

}