get Matrix from View - Android User Interface

Android examples for User Interface:View

Description

get Matrix from View

Demo Code


//package com.java2s;
import android.graphics.Matrix;
import android.os.Build;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;

public class Main {
    static Animation animation;
    static Transformation transformation;

    public static Matrix getMatrix(View view) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            return view.getMatrix();
        animation = view.getAnimation();
        if (animation == null)
            return new Matrix();
        transformation = new Transformation();
        animation.getTransformation(view.getDrawingTime(), transformation);
        return transformation.getMatrix();
    }/*  w  ww . j a  va 2s . c o  m*/
}

Related Tutorials