List of usage examples for android.view View getScaleX
@ViewDebug.ExportedProperty(category = "drawing") public float getScaleX()
From source file:Main.java
public static synchronized void animateScaleUp(View v, float targetScale) { float currentScaleX = v.getScaleX(); float currentScaleY = v.getScaleY(); PropertyValuesHolder scaleXHolder = PropertyValuesHolder.ofFloat(View.SCALE_X, currentScaleX, targetScale); PropertyValuesHolder scaleYHolder = PropertyValuesHolder.ofFloat(View.SCALE_Y, currentScaleY, targetScale); ValueAnimator scaleAnimator = ObjectAnimator.ofPropertyValuesHolder(v, scaleXHolder, scaleYHolder); scaleAnimator.start();/* w w w . jav a 2 s . co m*/ }
From source file:Main.java
public static synchronized void animateScaleDown(View v, float targetScale) { float currentScaleX = v.getScaleX(); float currentScaleY = v.getScaleY(); PropertyValuesHolder scaleXHolder = PropertyValuesHolder.ofFloat(View.SCALE_X, currentScaleX, targetScale); PropertyValuesHolder scaleYHolder = PropertyValuesHolder.ofFloat(View.SCALE_Y, currentScaleY, targetScale); ValueAnimator scaleAnimator = ObjectAnimator.ofPropertyValuesHolder(v, scaleXHolder, scaleYHolder); scaleAnimator.start();/* ww w . j av a2 s . c o m*/ }
From source file:Main.java
public static void startScaleAnime(final View view, float newScale, Animator.AnimatorListener listener) { ValueAnimator anime = ValueAnimator.ofFloat(view.getScaleX(), newScale); anime.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from w w w .ja v a 2 s . c o m public void onAnimationUpdate(ValueAnimator animation) { float s = Float.parseFloat(animation.getAnimatedValue().toString()); view.setScaleX(s); view.setScaleY(s); } }); if (listener != null) { anime.addListener(listener); } anime.setDuration(mAnimeDuration); anime.start(); }
From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticAction.java
public static void doAction(View view, int duration, float scaleX, float scaleY) { try {//from ww w. j a va 2s.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(); } } catch (Exception e) { Log.e(TAG, "only ViewGroups : likes RelativeLayout, LinearLayout, etc could doAction"); } }
From source file:Main.java
public static int[] getCenterDeltaInScreenSpace(View v0, View v1, int[] delta) { v0.getLocationInWindow(sLoc0);/*from w w w .ja v a 2 s. c om*/ v1.getLocationInWindow(sLoc1); sLoc0[0] += (v0.getMeasuredWidth() * v0.getScaleX()) / 2; sLoc0[1] += (v0.getMeasuredHeight() * v0.getScaleY()) / 2; sLoc1[0] += (v1.getMeasuredWidth() * v1.getScaleX()) / 2; sLoc1[1] += (v1.getMeasuredHeight() * v1.getScaleY()) / 2; if (delta == null) { delta = new int[2]; } delta[0] = sLoc1[0] - sLoc0[0]; delta[1] = sLoc1[1] - sLoc0[1]; return delta; }
From source file:Main.java
/** * Helps to show views./* w ww . j ava 2 s. c om*/ * * @param views Views to show. * @param animationDuration Animation duration. * @param animationDelay Animation delay. */ static void orderedShowViews(final List<View> views, long animationDuration, int animationDelay) { if (views != null) { for (int viewIndex = 0; viewIndex < views.size(); viewIndex++) { final View childView = views.get(viewIndex); childView.setVisibility(View.VISIBLE); final ScaleAnimation scaleAnimation = new ScaleAnimation(0, childView.getScaleX(), 0, childView.getScaleY(), Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); scaleAnimation.setInterpolator(new DecelerateInterpolator()); scaleAnimation.setDuration(animationDuration); scaleAnimation.setStartOffset(viewIndex * animationDelay); childView.startAnimation(scaleAnimation); } } }
From source file:Main.java
/** * Inverse of {@link #getDescendantCoordRelativeToSelf(View, int[])}. *//*from w ww .ja v a2s. co m*/ public static float mapCoordInSelfToDescendent(View descendant, View root, int[] coord) { ArrayList<View> ancestorChain = new ArrayList<View>(); float[] pt = { coord[0], coord[1] }; View v = descendant; while (v != root) { ancestorChain.add(v); v = (View) v.getParent(); } ancestorChain.add(root); float scale = 1.0f; Matrix inverse = new Matrix(); int count = ancestorChain.size(); for (int i = count - 1; i >= 0; i--) { View ancestor = ancestorChain.get(i); View next = i > 0 ? ancestorChain.get(i - 1) : null; pt[0] += ancestor.getScrollX(); pt[1] += ancestor.getScrollY(); if (next != null) { pt[0] -= next.getLeft(); pt[1] -= next.getTop(); next.getMatrix().invert(inverse); inverse.mapPoints(pt); scale *= next.getScaleX(); } } coord[0] = (int) Math.round(pt[0]); coord[1] = (int) Math.round(pt[1]); return scale; }
From source file:Main.java
/** * Maps a coorindate in a descendant view into the parent. *//*w w w. j ava 2 s . co m*/ public static float mapCoordInDescendentToSelf(View descendant, View root, float[] coord, boolean includeRootScroll) { ArrayList<View> ancestorChain = new ArrayList<View>(); float[] pt = { coord[0], coord[1] }; View v = descendant; while (v != root && v != null) { ancestorChain.add(v); v = (View) v.getParent(); } ancestorChain.add(root); float scale = 1.0f; int count = ancestorChain.size(); for (int i = 0; i < count; i++) { View v0 = ancestorChain.get(i); // For TextViews, scroll has a meaning which relates to the text position // which is very strange... ignore the scroll. if (v0 != descendant || includeRootScroll) { pt[0] -= v0.getScrollX(); pt[1] -= v0.getScrollY(); } v0.getMatrix().mapPoints(pt); pt[0] += v0.getLeft(); pt[1] += v0.getTop(); scale *= v0.getScaleX(); } coord[0] = pt[0]; coord[1] = pt[1]; return scale; }
From source file:Main.java
/** * Maps a coordinate in a descendant view into the parent. *//*from w w w . j a va 2 s.c o m*/ public static float mapCoordInDescendentToSelf(View descendant, View root, float[] coord, boolean includeRootScroll) { ArrayList<View> ancestorChain = new ArrayList<>(); float[] pt = { coord[0], coord[1] }; View v = descendant; while (v != root && v != null) { ancestorChain.add(v); v = (View) v.getParent(); } ancestorChain.add(root); float scale = 1.0f; int count = ancestorChain.size(); for (int i = 0; i < count; i++) { View v0 = ancestorChain.get(i); // For TextViews, scroll has a meaning which relates to the text position // which is very strange... ignore the scroll. if (v0 != descendant || includeRootScroll) { pt[0] -= v0.getScrollX(); pt[1] -= v0.getScrollY(); } v0.getMatrix().mapPoints(pt); pt[0] += v0.getLeft(); pt[1] += v0.getTop(); scale *= v0.getScaleX(); } coord[0] = pt[0]; coord[1] = pt[1]; return scale; }
From source file:Main.java
/** * Given a coordinate relative to the descendant, find the coordinate in a parent view's * coordinates.// w w w .ja va 2s. c om * * @param descendant The descendant to which the passed coordinate is relative. * @param root The root view to make the coordinates relative to. * @param coord The coordinate that we want mapped. * @param includeRootScroll Whether or not to account for the scroll of the descendant: * sometimes this is relevant as in a child's coordinates within the descendant. * @return The factor by which this descendant is scaled relative to this DragLayer. Caution * this scale factor is assumed to be equal in X and Y, and so if at any point this * assumption fails, we will need to return a pair of scale factors. */ public static float getDescendantCoordRelativeToParent(View descendant, View root, int[] coord, boolean includeRootScroll) { ArrayList<View> ancestorChain = new ArrayList<View>(); float[] pt = { coord[0], coord[1] }; View v = descendant; while (v != root && v != null) { ancestorChain.add(v); v = (View) v.getParent(); } ancestorChain.add(root); float scale = 1.0f; int count = ancestorChain.size(); for (int i = 0; i < count; i++) { View v0 = ancestorChain.get(i); // For TextViews, scroll has a meaning which relates to the text position // which is very strange... ignore the scroll. if (v0 != descendant || includeRootScroll) { pt[0] -= v0.getScrollX(); pt[1] -= v0.getScrollY(); } v0.getMatrix().mapPoints(pt); pt[0] += v0.getLeft(); pt[1] += v0.getTop(); scale *= v0.getScaleX(); } coord[0] = (int) Math.round(pt[0]); coord[1] = (int) Math.round(pt[1]); return scale; }