List of usage examples for android.view View getPivotX
@ViewDebug.ExportedProperty(category = "drawing") public float getPivotX()
From source file:Main.java
public static void updateAnimation(final View v) { final ScaleAnimation scaleInAnimation = new ScaleAnimation(v.getX(), v.getX() + 1, v.getY(), v.getY() + 1, v.getPivotX(), v.getPivotY()); scaleInAnimation.setDuration(200);//from w w w .j av a 2s . co m scaleInAnimation.setFillAfter(false); v.startAnimation(scaleInAnimation); }
From source file:org.protocoderrunner.apprunner.api.PUI.java
@ProtocoderScript @APIMethod(description = "Scales and moves a view to a given position and size", example = "") @APIParam(params = { "View", "x", "y", "w", "h" }) public void amplify(View v, float x, float y, float w, float h) { this.move(v, x, y); float pX = v.getPivotX(); float pY = v.getPivotY(); v.setPivotX(0);/*from w w w . ja va 2s .c o m*/ v.setPivotY(0); float sX = w / v.getWidth(); float sY = h / v.getHeight(); this.scale(v, sX, sY); v.setPivotX(pX); v.setPivotY(pY); }
From source file:com.kozhevin.example.carousel.CarouselLayoutManager.java
/** * The magic functions :). Scaled all item of ChildView array. * /*w w w.ja va 2s . c o m*/ * @param renderState * */ private void makeScaleView(RenderState renderState) { updateCenter(); if (mIsEnabledCalulateLappingItem) { if (renderState.mLayoutDirection == RenderState.LAYOUT_START) { // from left to right if (IS_DEBUG && IS_DEBUG_SCALE) { Log.w(TAG, "Scroll from left to right"); } if (getmOffsetForSmoothController() < 0) { setOffsetForSmoothController(-getmOffsetForSmoothController()); } mMinLappingValue = getWidth(); } else { mMinLappingValue = -getWidth(); if (IS_DEBUG && IS_DEBUG_SCALE) { Log.w(TAG, "Scroll from right to left"); } if (getmOffsetForSmoothController() > 0) { setOffsetForSmoothController(-getmOffsetForSmoothController()); } } mMinLappingItemIndex = 0; } float lCenterChild = 0; float lDeltaXCenterChild = 0; float lScaleValue = 0; for (int i = 0; i < getChildCount(); ++i) { View child = getChildAt(i); lCenterChild = child.getRight() - child.getPivotX(); lDeltaXCenterChild = mCenterScreen - lCenterChild; if (mIsEnabledCalulateLappingItem) { if (renderState.mLayoutDirection == RenderState.LAYOUT_START) { // from left to right if (lDeltaXCenterChild > 0 && mMinLappingValue > lDeltaXCenterChild) { mMinLappingValue = lDeltaXCenterChild; if (getPosition(child) > 0) { mMinLappingItemIndex = getPosition(child); // + 1; } else { mMinLappingItemIndex = 1; } if (IS_DEBUG && IS_DEBUG_SCALE) { Log.w(TAG, "mMinLappingValue = " + mMinLappingValue + " index = " + mMinLappingItemIndex); } } else if (lDeltaXCenterChild < 0 && mMinLappingItemIndex == getPosition(child) /*+ 1*/) { mMinLappingValue = getWidth(); if (IS_DEBUG && IS_DEBUG_SCALE) { Log.w(TAG, "mMinLappingValue = " + mMinLappingValue + " index = " + mMinLappingItemIndex); } } } else { if (lDeltaXCenterChild < 0 && mMinLappingValue < lDeltaXCenterChild) { mMinLappingValue = lDeltaXCenterChild; if (getPosition(child) < getItemCount() - 1) { mMinLappingItemIndex = getPosition(child); } else { if (IS_DEBUG && IS_DEBUG_SCALE) { Log.w(TAG, "Scrolled last position = " + getPosition(child) + ", set the penultimate position."); } mMinLappingItemIndex = getItemCount() - 2; } if (IS_DEBUG && IS_DEBUG_SCALE) { Log.w(TAG, "mMinLappingValue = " + mMinLappingValue + " index = " + mMinLappingItemIndex); } } else if (lDeltaXCenterChild > 0 && mMinLappingItemIndex == getPosition(child) + 1) { mMinLappingValue = -getWidth(); if (IS_DEBUG && IS_DEBUG_SCALE) { Log.w(TAG, "mMinLappingValue = " + mMinLappingValue + " index = " + mMinLappingItemIndex); } } } } if (IS_DEBUG && IS_DEBUG_SCALE) { Log.d(TAG, "lDeltaXCenterChild value = " + lDeltaXCenterChild); } /* * scale = a + b * cos(w / pi * dx) a = (max + min) / 2 b = (max - * min) / 2 dx - shift from the center max - the maximum value of * scale (1) min - the minimum value of scale w - When dx = 0, the * value of scale will be max, when dx = +w or -w, the value will be * min pi - math PI constant * * assume max = 1, min = 0.4; then a = 0.7, b = 0.3 */ lScaleValue = (float) (0.7 + 0.3 * Math.cos(lDeltaXCenterChild * Math.PI / getWidth() / 2)); if (IS_DEBUG) { Log.d(TAG, "scale value = " + lScaleValue); } if (lScaleValue < 0) { lScaleValue = 0; } if (lScaleValue > 1) { Log.e(TAG, "scale value = " + lScaleValue); } child.setScaleY(lScaleValue); child.setScaleX(lScaleValue); if (IS_DEBUG && IS_DEBUG_SCALE) { Log.d(TAG, "child index = " + i + " centerX = " + (child.getRight() - child.getPivotX())); } } }