Example usage for android.content.res Resources getAnimation

List of usage examples for android.content.res Resources getAnimation

Introduction

In this page you can find the example usage for android.content.res Resources getAnimation.

Prototype

@NonNull
public XmlResourceParser getAnimation(@AnimatorRes @AnimRes int id) throws NotFoundException 

Source Link

Document

Return an XmlResourceParser through which you can read an animation description for the given resource ID.

Usage

From source file:android.support.graphics.drawable.AnimatorInflaterCompat.java

/**
 * Loads an {@link Animator} object from a resource, context is for loading interpolator.
 *//*from w ww . j a v  a2s.  c  om*/
public static Animator loadAnimator(Context context, Resources resources, Theme theme, @AnimatorRes int id,
        float pathErrorScale) throws NotFoundException {
    Animator animator;

    XmlResourceParser parser = null;
    try {
        parser = resources.getAnimation(id);
        animator = createAnimatorFromXml(context, resources, theme, parser, pathErrorScale);
        return animator;
    } catch (XmlPullParserException ex) {
        Resources.NotFoundException rnf = new Resources.NotFoundException(
                "Can't load animation resource ID #0x" + Integer.toHexString(id));
        rnf.initCause(ex);
        throw rnf;
    } catch (IOException ex) {
        Resources.NotFoundException rnf = new Resources.NotFoundException(
                "Can't load animation resource ID #0x" + Integer.toHexString(id));
        rnf.initCause(ex);
        throw rnf;
    } finally {
        if (parser != null)
            parser.close();
    }
}