Example usage for android.view ViewGroup getScaleX

List of usage examples for android.view ViewGroup getScaleX

Introduction

In this page you can find the example usage for android.view ViewGroup getScaleX.

Prototype

@ViewDebug.ExportedProperty(category = "drawing")
public float getScaleX() 

Source Link

Document

The amount that the view is scaled in x around the pivot point, as a proportion of the view's unscaled width.

Usage

From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticAction.java

public static void doAction(ViewGroup view, int duration, float scaleX, float scaleY) {
    try {/*from  w w  w.j a v  a2s.  c o  m*/
        if (view.getScaleX() == 1) {
            ViewCompat.animate(view).setDuration(duration).scaleX(scaleX).scaleY(scaleY)
                    .setInterpolator(new CycleInterpolator(0.5f))
                    .setListener(new ViewPropertyAnimatorListener() {

                        @Override
                        public void onAnimationStart(final View view) {
                        }

                        @Override
                        public void onAnimationEnd(final View v) {
                        }

                        @Override
                        public void onAnimationCancel(final View view) {
                        }
                    }).withLayer().start();

            for (int index = 0; index < ((ViewGroup) view).getChildCount(); ++index) {
                View nextChild = ((ViewGroup) view).getChildAt(index);
                ViewCompat.animate(nextChild).setDuration(duration).scaleX(scaleX).scaleY(scaleY)
                        .setInterpolator(new CycleInterpolator(0.5f))
                        .setListener(new ViewPropertyAnimatorListener() {

                            @Override
                            public void onAnimationStart(final View view) {
                            }

                            @Override
                            public void onAnimationEnd(final View v) {
                            }

                            @Override
                            public void onAnimationCancel(final View view) {
                            }
                        }).withLayer().start();
            }
        }
    } catch (Exception e) {
        Log.e(TAG, "only ViewGroups : likes RelativeLayout, LinearLayout, etc could doAction");
    }
}