Java Code Examples for android.view.View#getScaleX()

The following examples show how to use android.view.View#getScaleX() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChangeTransform.java    From scene with Apache License 2.0 5 votes vote down vote up
Transforms(View view) {
    mTranslationX = view.getTranslationX();
    mTranslationY = view.getTranslationY();
    mTranslationZ = ViewCompat.getTranslationZ(view);
    mScaleX = view.getScaleX();
    mScaleY = view.getScaleY();
    mRotationX = view.getRotationX();
    mRotationY = view.getRotationY();
    mRotationZ = view.getRotation();
}
 
Example 2
Source File: MultiTouchListener.java    From photo-editor-android with MIT License 5 votes vote down vote up
private static void move(View view, TransformInfo info) {
    computeRenderOffset(view, info.pivotX, info.pivotY);
    adjustTranslation(view, info.deltaX, info.deltaY);

    float scale = view.getScaleX() * info.deltaScale;
    scale = Math.max(info.minimumScale, Math.min(info.maximumScale, scale));
    view.setScaleX(scale);
    view.setScaleY(scale);

    float rotation = adjustAngle(view.getRotation() + info.deltaAngle);
    view.setRotation(rotation);
}
 
Example 3
Source File: ChangeTransform.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public Transforms(View view) {
    translationX = view.getTranslationX();
    translationY = view.getTranslationY();
    translationZ = view.getTranslationZ();
    scaleX = view.getScaleX();
    scaleY = view.getScaleY();
    rotationX = view.getRotationX();
    rotationY = view.getRotationY();
    rotationZ = view.getRotation();
}
 
Example 4
Source File: LessonB.java    From SchoolQuest with GNU General Public License v3.0 5 votes vote down vote up
private boolean isViewOverlapping(View firstView, View secondView) {
    int[] firstPosition = new int[2];
    int[] secondPosition = new int[2];

    firstView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
    firstView.getLocationOnScreen(firstPosition);
    secondView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
    secondView.getLocationOnScreen(secondPosition);

    float firstWidth = firstView.getMeasuredWidth() * firstView.getScaleX();
    float secondWidth = secondView.getMeasuredWidth() * secondView.getScaleX();

    return firstPosition[0] < secondPosition[0] + secondWidth
            && firstPosition[0] + firstWidth > secondPosition[0];
}
 
Example 5
Source File: CellLayout.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
public ReorderPreviewAnimation(View child, int mode, int cellX0, int cellY0, int cellX1,
        int cellY1, int spanX, int spanY) {
    regionToCenterPoint(cellX0, cellY0, spanX, spanY, mTmpPoint);
    final int x0 = mTmpPoint[0];
    final int y0 = mTmpPoint[1];
    regionToCenterPoint(cellX1, cellY1, spanX, spanY, mTmpPoint);
    final int x1 = mTmpPoint[0];
    final int y1 = mTmpPoint[1];
    final int dX = x1 - x0;
    final int dY = y1 - y0;
    finalDeltaX = 0;
    finalDeltaY = 0;
    int dir = mode == MODE_HINT ? -1 : 1;
    if (dX == dY && dX == 0) {
    } else {
        if (dY == 0) {
            finalDeltaX = - dir * Math.signum(dX) * mReorderPreviewAnimationMagnitude;
        } else if (dX == 0) {
            finalDeltaY = - dir * Math.signum(dY) * mReorderPreviewAnimationMagnitude;
        } else {
            double angle = Math.atan( (float) (dY) / dX);
            finalDeltaX = (int) (- dir * Math.signum(dX) *
                    Math.abs(Math.cos(angle) * mReorderPreviewAnimationMagnitude));
            finalDeltaY = (int) (- dir * Math.signum(dY) *
                    Math.abs(Math.sin(angle) * mReorderPreviewAnimationMagnitude));
        }
    }
    this.mode = mode;
    initDeltaX = child.getTranslationX();
    initDeltaY = child.getTranslationY();
    finalScale = getChildrenScale() - 4.0f / child.getWidth();
    initScale = child.getScaleX();
    this.child = child;
}
 
Example 6
Source File: ViewDefault.java    From morphos with Apache License 2.0 5 votes vote down vote up
public void updateView(View v) {
    if (v != null) {
        this.alpha = v.getAlpha();
        this.x = v.getX();
        this.y = v.getY();
        this.z = atLeastLollipop ? v.getZ() : 0;
        this.width = v.getWidth();
        this.height = v.getHeight();
        this.expansionScaleX = v.getScaleX();
        this.expansionScaleY = v.getScaleY();
        this.dispositionAngle = v.getRotation();
        this.dispositionAngleX = v.getRotationX();
        this.dispositionAngleY = v.getRotationY();
    }
}
 
Example 7
Source File: ViewUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 获取 View 水平方向缩放比例
 * @param view View
 * @return View 水平方向缩放比例
 */
public static float getScaleX(final View view) {
    if (view != null) {
        return view.getScaleX();
    }
    return 0f;
}
 
Example 8
Source File: WXSliderNeighbor.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private void updateScaleAndAlpha(View view, float alpha, float scale) {
    if(null == view) {
        return;
    }
    if(alpha >= 0 && view.getAlpha() != alpha) {
        view.setAlpha(alpha);
    }
    if(scale >= 0 && view.getScaleX() != scale) {
        view.setScaleX(scale);
        view.setScaleY(scale);
    }
}
 
Example 9
Source File: Scale.java    From Transitions-Everywhere with Apache License 2.0 5 votes vote down vote up
@Nullable
private Animator createAnimation(@NonNull final View view, float startScale, float endScale, @Nullable TransitionValues values) {
    final float initialScaleX = view.getScaleX();
    final float initialScaleY = view.getScaleY();
    float startScaleX = initialScaleX * startScale;
    float endScaleX = initialScaleX * endScale;
    float startScaleY = initialScaleY * startScale;
    float endScaleY = initialScaleY * endScale;

    if (values != null) {
        Float savedScaleX = (Float) values.values.get(PROPNAME_SCALE_X);
        Float savedScaleY = (Float) values.values.get(PROPNAME_SCALE_Y);
        // if saved value is not equal initial value it means that previous
        // transition was interrupted and in the onTransitionEnd
        // we've applied endScale. we should apply proper value to
        // continue animation from the interrupted state
        if (savedScaleX != null && savedScaleX != initialScaleX) {
            startScaleX = savedScaleX;
        }
        if (savedScaleY != null && savedScaleY != initialScaleY) {
            startScaleY = savedScaleY;
        }
    }

    view.setScaleX(startScaleX);
    view.setScaleY(startScaleY);

    Animator animator = TransitionUtils.mergeAnimators(
        ObjectAnimator.ofFloat(view, View.SCALE_X, startScaleX, endScaleX),
        ObjectAnimator.ofFloat(view, View.SCALE_Y, startScaleY, endScaleY));
    addListener(new TransitionListenerAdapter() {
        @Override
        public void onTransitionEnd(@NonNull Transition transition) {
            view.setScaleX(initialScaleX);
            view.setScaleY(initialScaleY);
            transition.removeListener(this);
        }
    });
    return animator;
}
 
Example 10
Source File: ChangeTransform.java    From Transitions-Everywhere with Apache License 2.0 5 votes vote down vote up
public Transforms(View view) {
    translationX = view.getTranslationX();
    translationY = view.getTranslationY();
    translationZ = ViewUtils.getTranslationZ(view);
    scaleX = view.getScaleX();
    scaleY = view.getScaleY();
    rotationX = view.getRotationX();
    rotationY = view.getRotationY();
    rotationZ = view.getRotation();
}
 
Example 11
Source File: PushDownAnim.java    From pushdown-anim-click with Apache License 2.0 4 votes vote down vote up
private PushDownAnim( final View view ){
    this.weakView = new WeakReference<>(view) ;
    this.weakView.get().setClickable( true );
    defaultScale = view.getScaleX();
}
 
Example 12
Source File: DragLayer.java    From LB-Launcher with Apache License 2.0 4 votes vote down vote up
public void animateViewIntoPosition(DragView dragView, final View child, int duration,
        final Runnable onFinishAnimationRunnable, View anchorView) {
    ShortcutAndWidgetContainer parentChildren = (ShortcutAndWidgetContainer) child.getParent();
    CellLayout.LayoutParams lp =  (CellLayout.LayoutParams) child.getLayoutParams();
    parentChildren.measureChild(child);

    Rect r = new Rect();
    getViewRectRelativeToSelf(dragView, r);

    int coord[] = new int[2];
    float childScale = child.getScaleX();
    coord[0] = lp.x + (int) (child.getMeasuredWidth() * (1 - childScale) / 2);
    coord[1] = lp.y + (int) (child.getMeasuredHeight() * (1 - childScale) / 2);

    // Since the child hasn't necessarily been laid out, we force the lp to be updated with
    // the correct coordinates (above) and use these to determine the final location
    float scale = getDescendantCoordRelativeToSelf((View) child.getParent(), coord);
    // We need to account for the scale of the child itself, as the above only accounts for
    // for the scale in parents.
    scale *= childScale;
    int toX = coord[0];
    int toY = coord[1];
    float toScale = scale;
    if (child instanceof TextView) {
        TextView tv = (TextView) child;
        // Account for the source scale of the icon (ie. from AllApps to Workspace, in which
        // the workspace may have smaller icon bounds).
        toScale = scale / dragView.getIntrinsicIconScaleFactor();

        // The child may be scaled (always about the center of the view) so to account for it,
        // we have to offset the position by the scaled size.  Once we do that, we can center
        // the drag view about the scaled child view.
        toY += Math.round(toScale * tv.getPaddingTop());
        toY -= dragView.getMeasuredHeight() * (1 - toScale) / 2;
        if (dragView.getDragVisualizeOffset() != null) {
            toY -=  Math.round(toScale * dragView.getDragVisualizeOffset().y);
        }

        toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
    } else if (child instanceof FolderIcon) {
        // Account for holographic blur padding on the drag view
        toY += Math.round(scale * (child.getPaddingTop() - dragView.getDragRegionTop()));
        toY -= scale * Workspace.DRAG_BITMAP_PADDING / 2;
        toY -= (1 - scale) * dragView.getMeasuredHeight() / 2;
        // Center in the x coordinate about the target's drawable
        toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
    } else {
        toY -= (Math.round(scale * (dragView.getHeight() - child.getMeasuredHeight()))) / 2;
        toX -= (Math.round(scale * (dragView.getMeasuredWidth()
                - child.getMeasuredWidth()))) / 2;
    }

    final int fromX = r.left;
    final int fromY = r.top;
    child.setVisibility(INVISIBLE);
    Runnable onCompleteRunnable = new Runnable() {
        public void run() {
            child.setVisibility(VISIBLE);
            if (onFinishAnimationRunnable != null) {
                onFinishAnimationRunnable.run();
            }
        }
    };
    animateViewIntoPosition(dragView, fromX, fromY, toX, toY, 1, 1, 1, toScale, toScale,
            onCompleteRunnable, ANIMATION_END_DISAPPEAR, duration, anchorView);
}
 
Example 13
Source File: ScaleXAnimationPropertyUpdater.java    From react-native-GPay with MIT License 4 votes vote down vote up
@Override
protected float getProperty(View view) {
  return view.getScaleX();
}
 
Example 14
Source File: ViewHelper.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
static float getScaleX(View view) {
    return view.getScaleX();
}
 
Example 15
Source File: ScaleProperty.java    From WIFIADB with Apache License 2.0 4 votes vote down vote up
@Override
public Float get(View object) {
    return object.getScaleX();
}
 
Example 16
Source File: AnimationUtils.java    From social-app-android with Apache License 2.0 4 votes vote down vote up
public static boolean isViewHiddenByScale(View v) {
    return v.getScaleX() == 0 && v.getScaleY() == 0;
}
 
Example 17
Source File: a.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
static float g(View view)
{
    return view.getScaleX();
}
 
Example 18
Source File: DragLayer.java    From TurboLauncher with Apache License 2.0 4 votes vote down vote up
public void animateViewIntoPosition(DragView dragView, final View child, int duration,
        final Runnable onFinishAnimationRunnable, View anchorView) {
    ShortcutAndWidgetContainer parentChildren = (ShortcutAndWidgetContainer) child.getParent();
    CellLayout.LayoutParams lp =  (CellLayout.LayoutParams) child.getLayoutParams();
    parentChildren.measureChild(child);

    Rect r = new Rect();
    getViewRectRelativeToSelf(dragView, r);

    int coord[] = new int[2];
    float childScale = child.getScaleX();
    coord[0] = lp.x + (int) (child.getMeasuredWidth() * (1 - childScale) / 2);
    coord[1] = lp.y + (int) (child.getMeasuredHeight() * (1 - childScale) / 2);

    // Since the child hasn't necessarily been laid out, we force the lp to be updated with
    // the correct coordinates (above) and use these to determine the final location
    float scale = getDescendantCoordRelativeToSelf((View) child.getParent(), coord);
    // We need to account for the scale of the child itself, as the above only accounts for
    // for the scale in parents.
    scale *= childScale;
    int toX = coord[0];
    int toY = coord[1];
    float toScale = scale;
    if (child instanceof TextView) {
        TextView tv = (TextView) child;
        // Account for the source scale of the icon (ie. from AllApps to Workspace, in which
        // the workspace may have smaller icon bounds).
        toScale = scale / dragView.getIntrinsicIconScaleFactor();

        // The child may be scaled (always about the center of the view) so to account for it,
        // we have to offset the position by the scaled size.  Once we do that, we can center
        // the drag view about the scaled child view.
        toY += Math.round(toScale * tv.getPaddingTop());
        toY -= dragView.getMeasuredHeight() * (1 - toScale) / 2;
        toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
    } else if (child instanceof FolderIcon) {
        // Account for holographic blur padding on the drag view
        toY += Math.round(scale * (child.getPaddingTop() - dragView.getDragRegionTop()));
        toY -= scale * Workspace.DRAG_BITMAP_PADDING / 2;
        toY -= (1 - scale) * dragView.getMeasuredHeight() / 2;
        // Center in the x coordinate about the target's drawable
        toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
    } else {
        toY -= (Math.round(scale * (dragView.getHeight() - child.getMeasuredHeight()))) / 2;
        toX -= (Math.round(scale * (dragView.getMeasuredWidth()
                - child.getMeasuredWidth()))) / 2;
    }

    final int fromX = r.left;
    final int fromY = r.top;
    child.setVisibility(INVISIBLE);
    Runnable onCompleteRunnable = new Runnable() {
        public void run() {
            child.setVisibility(VISIBLE);
            if (onFinishAnimationRunnable != null) {
                onFinishAnimationRunnable.run();
            }
        }
    };
    animateViewIntoPosition(dragView, fromX, fromY, toX, toY, 1, 1, 1, toScale, toScale,
            onCompleteRunnable, ANIMATION_END_DISAPPEAR, duration, anchorView);
}
 
Example 19
Source File: ViewUtils.java    From MultiView with Apache License 2.0 4 votes vote down vote up
public static boolean isItemAtPoint(View view, float x, float y) {
    return (view.getLeft() < x) && (view.getLeft() + view.getWidth() * view.getScaleX() > x)
            && (view.getTop() < y) && (view.getTop() + view.getHeight() * view.getScaleY() > y)
            ;

}
 
Example 20
Source File: OverFlyingLayoutManager.java    From RecyclerBanner with Apache License 2.0 2 votes vote down vote up
/**
 * cause elevation is not support below api 21,
 * so you can set your elevation here for supporting it below api 21
 * or you can just setElevation in {@link #setItemViewProperty(View, float)}
 */
protected float setViewElevation(View itemView, float targetOffset) {
    return itemView.getScaleX() * 5;
}