android.view.animation.ScaleAnimation#setDuration()源码实例Demo

下面列出了android.view.animation.ScaleAnimation#setDuration() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: bither-android   文件: RawDataBinaryView.java
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);
        }
    }
}
 
源代码2 项目: actor-platform   文件: ViewUtils.java
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);
    }

}
 
源代码3 项目: RecyclerWheelPicker   文件: WheelPicker.java
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);
    }
}
 
/**
 * 中间的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);
}
 
源代码5 项目: YuanNewsForAndroid   文件: AnimationLoader.java
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;
}
 
源代码6 项目: stynico   文件: bilibili.java
@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);
   }
 
源代码7 项目: Conquer   文件: RippleView.java
@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);
}
 
源代码8 项目: TvWidget   文件: AnimateFactory.java
/**
 * 缩放动画,用于缩放控件
 *
 * @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;
}
 
源代码9 项目: BaseProject   文件: RippleView.java
@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);
}
 
源代码10 项目: YuanNewsForAndroid   文件: AnimationLoader.java
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;
}
 
源代码11 项目: actor-platform   文件: ViewUtils.java
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);

}
 
源代码12 项目: android-WatchViewStub   文件: MainActivity.java
/**
 * 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();
    }
}
 
源代码13 项目: UltimateAndroid   文件: RippleView.java
@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);
}
 
源代码14 项目: CatchPiggy   文件: ClassicMode.java
/**
 格子触摸时的动画
 */
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;
}
 
源代码15 项目: In77Camera   文件: EffectsButton.java
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;
}
 
源代码16 项目: DoubanTop   文件: RippleView.java
@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);
}
 
源代码17 项目: sketch   文件: ZoomOutImageDisplayer.java
@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);
}
 
源代码18 项目: CatchPiggy   文件: AnimationButton.java
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;
}
 
源代码19 项目: glass_snippets   文件: CameraService.java
@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());
	}
}
 
源代码20 项目: AndroidStudyDemo   文件: AnimationUtil.java
/**
 * 获取一个缩小动画
 *
 * @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;
}