Search in sources :

Example 1 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project UltimateAndroid by cymcsg.

the class RippleView method onSizeChanged.

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    WIDTH = w;
    HEIGHT = h;
    scaleAnimation = new ScaleAnimation(1.0f, zoomScale, 1.0f, zoomScale, w / 2, h / 2);
    scaleAnimation.setDuration(zoomDuration);
    scaleAnimation.setRepeatMode(Animation.REVERSE);
    scaleAnimation.setRepeatCount(1);
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation)

Example 2 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project ArcMenu by daCapricorn.

the class RayMenu method createItemDisapperAnimation.

private static Animation createItemDisapperAnimation(final long duration, final boolean isClicked) {
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(new ScaleAnimation(1.0f, isClicked ? 2.0f : 0.0f, 1.0f, isClicked ? 2.0f : 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
    animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f));
    animationSet.setDuration(duration);
    animationSet.setInterpolator(new DecelerateInterpolator());
    animationSet.setFillAfter(true);
    return animationSet;
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 3 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project StickerCamera by Skykai521.

the class CameraActivity method initEvent.

private void initEvent() {
    //拍照
    takePicture.setOnClickListener(v -> {
        try {
            cameraInst.takePicture(null, null, new MyPictureCallback());
        } catch (Throwable t) {
            t.printStackTrace();
            toast("拍照失败,请重试!", Toast.LENGTH_LONG);
            try {
                cameraInst.startPreview();
            } catch (Throwable e) {
            }
        }
    });
    //闪光灯
    flashBtn.setOnClickListener(v -> turnLight(cameraInst));
    //前后置摄像头切换
    boolean canSwitch = false;
    try {
        canSwitch = mCameraHelper.hasFrontCamera() && mCameraHelper.hasBackCamera();
    } catch (Exception e) {
    //获取相机信息失败
    }
    if (!canSwitch) {
        changeBtn.setVisibility(View.GONE);
    } else {
        changeBtn.setOnClickListener(v -> switchCamera());
    }
    //跳转相册
    galleryBtn.setOnClickListener(v -> startActivity(new Intent(CameraActivity.this, AlbumActivity.class)));
    //返回按钮
    backBtn.setOnClickListener(v -> finish());
    surfaceView.setOnTouchListener((v, event) -> {
        switch(event.getAction() & MotionEvent.ACTION_MASK) {
            // 主点按下
            case MotionEvent.ACTION_DOWN:
                pointX = event.getX();
                pointY = event.getY();
                mode = FOCUS;
                break;
            // 副点按下
            case MotionEvent.ACTION_POINTER_DOWN:
                dist = spacing(event);
                // 如果连续两点距离大于10,则判定为多点模式
                if (spacing(event) > 10f) {
                    mode = ZOOM;
                }
                break;
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_POINTER_UP:
                mode = FOCUS;
                break;
            case MotionEvent.ACTION_MOVE:
                if (mode == FOCUS) {
                //pointFocus((int) event.getRawX(), (int) event.getRawY());
                } else if (mode == ZOOM) {
                    float newDist = spacing(event);
                    if (newDist > 10f) {
                        float tScale = (newDist - dist) / dist;
                        if (tScale < 0) {
                            tScale = tScale * 10;
                        }
                        addZoomIn((int) tScale);
                    }
                }
                break;
        }
        return false;
    });
    surfaceView.setOnClickListener(v -> {
        try {
            pointFocus((int) pointX, (int) pointY);
        } catch (Exception e) {
            e.printStackTrace();
        }
        RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams(focusIndex.getLayoutParams());
        layout.setMargins((int) pointX - 60, (int) pointY - 60, 0, 0);
        focusIndex.setLayoutParams(layout);
        focusIndex.setVisibility(View.VISIBLE);
        ScaleAnimation sa = new ScaleAnimation(3f, 1f, 3f, 1f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
        sa.setDuration(800);
        focusIndex.startAnimation(sa);
        handler.postDelayed(() -> focusIndex.setVisibility(View.INVISIBLE), 800);
    });
    takePhotoPanel.setOnClickListener(v -> {
    });
}
Also used : RelativeLayout(android.widget.RelativeLayout) Intent(android.content.Intent) IOException(java.io.IOException) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 4 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project storymaker by StoryMaker.

the class DraggableGridView method animateDragged.

//EVENT HELPERS
protected void animateDragged() {
    View v = getChildAt(dragged);
    int x = getCoorFromIndex(dragged).x + childSize / 2, y = getCoorFromIndex(dragged).y + childSize / 2;
    int l = x - (3 * childSize / 4), t = y - (3 * childSize / 4);
    v.layout(l, t, l + (childSize * 3 / 2), t + (childSize * 3 / 2));
    AnimationSet animSet = new AnimationSet(true);
    ScaleAnimation scale = new ScaleAnimation(.667f, 1, .667f, 1, childSize * 3 / 4, childSize * 3 / 4);
    scale.setDuration(animT);
    AlphaAnimation alpha = new AlphaAnimation(1, .5f);
    alpha.setDuration(animT);
    animSet.addAnimation(scale);
    animSet.addAnimation(alpha);
    animSet.setFillEnabled(true);
    animSet.setFillAfter(true);
    v.clearAnimation();
    v.startAnimation(animSet);
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) AnimationSet(android.view.animation.AnimationSet) Point(android.graphics.Point) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 5 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project Signal-Android by WhisperSystems.

the class HidingLinearLayout method show.

public void show() {
    if (!isEnabled() || getVisibility() == VISIBLE)
        return;
    setVisibility(VISIBLE);
    AnimationSet animation = new AnimationSet(true);
    animation.addAnimation(new ScaleAnimation(0, 1, 1, 1, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0.5f));
    animation.addAnimation(new AlphaAnimation(0, 1));
    animation.setDuration(100);
    animateWith(animation);
}
Also used : AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Aggregations

ScaleAnimation (android.view.animation.ScaleAnimation)114 AnimationSet (android.view.animation.AnimationSet)60 AlphaAnimation (android.view.animation.AlphaAnimation)56 Animation (android.view.animation.Animation)50 TranslateAnimation (android.view.animation.TranslateAnimation)40 ClipRectAnimation (android.view.animation.ClipRectAnimation)28 CurvedTranslateAnimation (com.android.server.wm.animation.CurvedTranslateAnimation)28 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)26 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)26 WindowAnimation_activityOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation)26 WindowAnimation_activityOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation)26 WindowAnimation_taskCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation)26 WindowAnimation_taskCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation)26 WindowAnimation_taskOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation)26 WindowAnimation_taskOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation)26 WindowAnimation_taskToBackEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation)26 WindowAnimation_taskToBackExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation)26 WindowAnimation_taskToFrontEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation)26 WindowAnimation_taskToFrontExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation)26 WindowAnimation_wallpaperCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation)26