Java Code Examples for android.view.animation.ScaleAnimation#setDuration()

The following examples show how to use android.view.animation.ScaleAnimation#setDuration() . 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: AnimationLoader.java    From YuanNewsForAndroid with Apache License 2.0 6 votes vote down vote up
public static AnimationSet getInAnimation(Context context) {
    AnimationSet in = new AnimationSet(context, null);

    AlphaAnimation alpha = new AlphaAnimation(0.0f, 1.0f);
    alpha.setDuration(90);

    ScaleAnimation scale1 = new ScaleAnimation(0.8f, 1.05f, 0.8f, 1.05f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scale1.setDuration(135);

    ScaleAnimation scale2 = new ScaleAnimation(1.05f, 0.95f, 1.05f, 0.95f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scale2.setDuration(105);
    scale2.setStartOffset(135);

    ScaleAnimation scale3 = new ScaleAnimation(0.95f, 1f, 0.95f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scale3.setDuration(60);
    scale3.setStartOffset(240);

    in.addAnimation(alpha);
    in.addAnimation(scale1);
    in.addAnimation(scale2);
    in.addAnimation(scale3);

    return in;
}
 
Example 2
Source File: RawDataBinaryView.java    From bither-android with Apache License 2.0 6 votes vote down vote up
public void removeAllData(){
    int size = data.size();
    data.clear();
    for(int i = 0; i < size; i++){
        final ImageView iv = (ImageView) ((FrameLayout) getChildAt(i)).getChildAt(0);
        if(iv.getVisibility() == View.VISIBLE){
            ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF,
                    0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            anim.setDuration(300);
            anim.setFillAfter(true);
            iv.startAnimation(anim);
            iv.postDelayed(new Runnable() {
                @Override
                public void run() {
                    iv.setVisibility(View.INVISIBLE);
                }
            }, 300);
        }
    }
}
 
Example 3
Source File: ViewUtils.java    From actor-platform with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void zoomInView(final View view) {
    if (view == null) {
        return;
    }


    if (view.getVisibility() != View.VISIBLE) {
        ScaleAnimation scaleAnimation = new ScaleAnimation(0, 1f, 0, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        scaleAnimation.setDuration(150);
        scaleAnimation.setInterpolator(MaterialInterpolator.getInstance());
        view.clearAnimation();
        view.startAnimation(scaleAnimation);
        view.setVisibility(View.VISIBLE);
    }

}
 
Example 4
Source File: WheelPicker.java    From RecyclerWheelPicker with Apache License 2.0 6 votes vote down vote up
public void doEnterAnim(final View contentView, long animDuration) {
    if (builder.gravity == Gravity.BOTTOM) {
        ValueAnimator enterAnimator = ValueAnimator.ofFloat(contentView.getHeight(), 0);
        enterAnimator.setDuration(animDuration);
        enterAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float value = (float) animation.getAnimatedValue();
                contentView.setTranslationY(value);
            }
        });
        enterAnimator.start();
    } else {
        ScaleAnimation scaleAnimation = new ScaleAnimation(0F, 1.0F, 0F, 1.0F,
                Animation.RELATIVE_TO_PARENT, 0.5F, Animation.RELATIVE_TO_PARENT, 0.5F);
        scaleAnimation.setDuration(animDuration);
        scaleAnimation.setFillAfter(true);
        contentView.startAnimation(scaleAnimation);
    }
}
 
Example 5
Source File: DynamicRotationGuideView.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 中间的View动画播放
 */
private void playCenter() {
    AnimationSet animationSet = new AnimationSet(false);
    ScaleAnimation scaleSmall = new ScaleAnimation(1.0f, 0.6f, 1.0f, 0.6f,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    ScaleAnimation scaleBig = new ScaleAnimation(1.0f, 5.0f/3, 1.0f, 5.0f/3,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scaleBig.setDuration(2*1000);
    scaleBig.setInterpolator(interpolator);
    scaleSmall.setDuration(2*1000);
    scaleSmall.setStartOffset(2*1000);
    scaleSmall.setRepeatCount(-1);
    scaleSmall.setFillEnabled(true);
    scaleSmall.setFillAfter(true);
    scaleBig.setStartOffset(2*1000);
    scaleBig.setRepeatCount(-1);
    scaleBig.setFillEnabled(true);
    scaleBig.setFillAfter(true);
    scaleSmall.setInterpolator(interpolator);
    animationSet.addAnimation(scaleBig);
    animationSet.addAnimation(scaleSmall);
    center.startAnimation(animationSet);
}
 
Example 6
Source File: ZoomOutImageDisplayer.java    From sketch with Apache License 2.0 5 votes vote down vote up
@Override
public void display(@NonNull SketchView sketchView, @NonNull Drawable newDrawable) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(fromX, 1.0f, fromY, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scaleAnimation.setInterpolator(interpolator);
    scaleAnimation.setDuration(duration);
    sketchView.clearAnimation();
    sketchView.setImageDrawable(newDrawable);
    sketchView.startAnimation(scaleAnimation);
}
 
Example 7
Source File: bilibili.java    From stynico with MIT License 5 votes vote down vote up
@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);
   }
 
Example 8
Source File: RippleView.java    From DoubanTop with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 9
Source File: EffectsButton.java    From In77Camera with MIT License 5 votes vote down vote up
ScaleAnimation createUpAnim() {
    ScaleAnimation localScaleAnimation = new ScaleAnimation(1.2F, 1.0F, 1.2F, 1.0F, 1, 0.5F, 1, 0.5F);
    localScaleAnimation.setDuration(50L);
    localScaleAnimation.setFillEnabled(true);
    localScaleAnimation.setFillEnabled(false);
    localScaleAnimation.setFillAfter(true);
    return localScaleAnimation;
}
 
Example 10
Source File: ClassicMode.java    From CatchPiggy with GNU General Public License v3.0 5 votes vote down vote up
/**
 格子触摸时的动画
 */
public Animation getItemTouchAnimation() {
    ScaleAnimation scaleAnimation = new ScaleAnimation(1, .7F, 1, .7F, Animation.RELATIVE_TO_SELF, .5F, Animation.RELATIVE_TO_SELF, .5F);
    scaleAnimation.setDuration(130);
    scaleAnimation.setRepeatCount(1);
    scaleAnimation.setRepeatMode(Animation.REVERSE);
    return scaleAnimation;
}
 
Example 11
Source File: RippleView.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 12
Source File: MainActivity.java    From android-WatchViewStub with Apache License 2.0 5 votes vote down vote up
/**
 * Animates the layout when clicked. The animation used depends on whether the
 * device is round or rectangular.
 */
public void onLayoutClicked(View view) {
    if (mRectBackground != null) {
        ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.7f, 1.0f, 0.7f,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        scaleAnimation.setDuration(300);
        scaleAnimation.setRepeatCount(1);
        scaleAnimation.setRepeatMode(Animation.REVERSE);
        mRectBackground.startAnimation(scaleAnimation);
    }
    if (mRoundBackground != null) {
        mRoundBackground.animate().rotationBy(360).setDuration(300).start();
    }
}
 
Example 13
Source File: ViewUtils.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void elevateView(final View view, boolean isAnimated, float scale) {
    if (view == null) {
        return;
    }


    ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, scale, 1.0f, scale, Animation.RELATIVE_TO_SELF, (float) 0.5, Animation.RELATIVE_TO_SELF, (float) 0.5);
    scaleAnimation.setDuration(isAnimated ? 150 : 0);
    scaleAnimation.setInterpolator(MaterialInterpolator.getInstance());
    scaleAnimation.setFillAfter(true);
    view.clearAnimation();
    view.startAnimation(scaleAnimation);

}
 
Example 14
Source File: AnimationLoader.java    From YuanNewsForAndroid with Apache License 2.0 5 votes vote down vote up
public static AnimationSet getOutAnimation(Context context) {
    AnimationSet out = new AnimationSet(context, null);
    AlphaAnimation alpha = new AlphaAnimation(1.0f, 0.0f);
    alpha.setDuration(150);
    ScaleAnimation scale = new ScaleAnimation(1.0f, 0.6f, 1.0f, 0.6f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scale.setDuration(150);
    out.addAnimation(alpha);
    out.addAnimation(scale);
    return out;
}
 
Example 15
Source File: RippleView.java    From BaseProject with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 16
Source File: AnimateFactory.java    From TvWidget with Apache License 2.0 5 votes vote down vote up
/**
 * 缩放动画,用于缩放控件
 *
 * @param startScale 控件的起始尺寸倍率
 * @param endScale   控件的终点尺寸倍率
 * @return
 */
public static Animation zoomAnimation(float startScale, float endScale, long duration) {
    ScaleAnimation anim = new ScaleAnimation(startScale, endScale, startScale, endScale,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    anim.setFillAfter(true);
    anim.setDuration(duration);
    return anim;
}
 
Example 17
Source File: RippleView.java    From Conquer with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 18
Source File: AnimationButton.java    From CatchPiggy with GNU General Public License v3.0 4 votes vote down vote up
private Animation getActionDownAnimation() {
    ScaleAnimation animation = new ScaleAnimation(1, .9F, 1, .9F, Animation.RELATIVE_TO_SELF, .5F, Animation.RELATIVE_TO_SELF, .5F);
    animation.setDuration(150);
    animation.setFillAfter(true);
    return animation;
}
 
Example 19
Source File: CameraService.java    From glass_snippets with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
	camera = Camera.open();
	try {
		mediaRecorder = new MediaRecorder();

		List<int[]> fps = camera.getParameters().getSupportedPreviewFpsRange();
		int preview_fps[] = fps.get(0);

		for (int i[] : camera.getParameters().getSupportedPreviewFpsRange())
			preview_fps = (mCaptureRate <= i[1] && mCaptureRate > i[0]) ? i : preview_fps;

		Camera.Parameters param = camera.getParameters();
		param.setVideoStabilization(true);
		param.setPreviewFpsRange(preview_fps[0], preview_fps[1]);
		camera.setParameters(param);
		camera.unlock();

		mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
		mediaRecorder.setCamera(camera);

		mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
		CamcorderProfile profile;
		if (mCaptureRate > 25) {
			mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
			profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
		} else {
			profile = CamcorderProfile.get(CamcorderProfile.QUALITY_TIME_LAPSE_HIGH);
			mediaRecorder.setCaptureRate(mCaptureRate);
			profile.videoFrameRate = ((int) Math.ceil(mCaptureRate));
		}

		mediaRecorder.setProfile(profile);
		mediaRecorder.setOutputFile(mOutFile);

		mediaRecorder.prepare();
		mediaRecorder.start();

		ScaleAnimation a = new ScaleAnimation(3, 2, 3, 2);
		a.setDuration(2000);
		surfaceView.startAnimation(a);

		Log.i(TAG, String.format("recording %s with rate %.2f", mOutFile, mCaptureRate));
	} catch(Exception e) {
		onDestroy();
		Log.d(TAG, e.toString());
	}
}
 
Example 20
Source File: AnimationUtil.java    From AndroidStudyDemo with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 获取一个缩小动画
 *
 * @param durationMillis
 * @param animationListener
 * @return
 */
public static ScaleAnimation getLessenScaleAnimation(long durationMillis, AnimationListener animationListener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, ScaleAnimation.RELATIVE_TO_SELF, ScaleAnimation.RELATIVE_TO_SELF);
    scaleAnimation.setDuration(durationMillis);
    scaleAnimation.setAnimationListener(animationListener);
    return scaleAnimation;
}