Example usage for android.view.animation ScaleAnimation ScaleAnimation

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

Introduction

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

Prototype

public ScaleAnimation(Context context, AttributeSet attrs) 

Source Link

Document

Constructor used when a ScaleAnimation is loaded from a resource.

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;/*from  ww w . j a v  a2  s  .c om*/

    // 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;

}