类android.view.animation.ScaleAnimation源码实例Demo

下面列出了怎么用android.view.animation.ScaleAnimation的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: material-sheet-fab   文件: Fab.java
/**
 * Hides the FAB.
 */
@Override
public void hide() {
	// Only use scale animation if FAB is visible
	if (getVisibility() == View.VISIBLE) {
		// Pivots indicate where the animation begins from
		float pivotX = getPivotX() + getTranslationX();
		float pivotY = getPivotY() + getTranslationY();

		// Animate FAB shrinking
		ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, pivotX, pivotY);
		anim.setDuration(FAB_ANIM_DURATION);
		anim.setInterpolator(getInterpolator());
		startAnimation(anim);
	}
	setVisibility(View.INVISIBLE);
}
 
源代码2 项目: mollyim-android   文件: MicrophoneRecorderView.java
void hide() {
  recordButtonFab.setTranslationX(0);
  recordButtonFab.setTranslationY(0);
  if (recordButtonFab.getVisibility() != VISIBLE) return;

  AnimationSet animation = new AnimationSet(false);
  Animation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 0.5f,
                                                Animation.RELATIVE_TO_SELF, 0.5f,
                                                Animation.RELATIVE_TO_SELF, 0.5f);

  Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, lastOffsetX,
                                                        Animation.ABSOLUTE, 0,
                                                        Animation.ABSOLUTE, lastOffsetY,
                                                        Animation.ABSOLUTE, 0);

  scaleAnimation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));
  translateAnimation.setInterpolator(new DecelerateInterpolator());
  animation.addAnimation(scaleAnimation);
  animation.addAnimation(translateAnimation);
  animation.setDuration(ANIMATION_DURATION);
  animation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));

  recordButtonFab.setVisibility(View.GONE);
  recordButtonFab.clearAnimation();
  recordButtonFab.startAnimation(animation);
}
 
源代码3 项目: 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;
}
 
源代码4 项目: bcm-android   文件: VoiceRecodingPanel.java
private void display(float x) {
    this.startPositionX = x;
    this.lastPositionX = x;

    recordButtonFab.setVisibility(VISIBLE);
    recordButtonFab.setX(getWidthAdjustment() + getOffset(x));

    AnimationSet animation = new AnimationSet(true);

    ScaleAnimation scaleAnimation = new ScaleAnimation(0.5f, 1f, 0.5f, 1f,
            Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    animation.addAnimation(scaleAnimation);
    animation.setFillBefore(true);
    animation.setFillAfter(true);
    animation.setDuration(ANIMATION_DURATION);
    animation.setInterpolator(new OvershootInterpolator());

    recordButtonFab.startAnimation(animation);
}
 
源代码5 项目: osmdroid   文件: MapController.java
public MapController(MapView mapView) {
    mMapView = mapView;

    // Keep track of initial layout
    mReplayController = new ReplayController();
    if (!mMapView.isLayoutOccurred()) {
        mMapView.addOnFirstLayoutListener(this);
    }


    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        ZoomAnimationListener zoomAnimationListener = new ZoomAnimationListener(this);
        mZoomInAnimationOld = new ScaleAnimation(1, 2, 1, 2, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
        mZoomOutAnimationOld = new ScaleAnimation(1, 0.5f, 1, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        mZoomInAnimationOld.setDuration(Configuration.getInstance().getAnimationSpeedShort());
        mZoomOutAnimationOld.setDuration(Configuration.getInstance().getAnimationSpeedShort());
        mZoomInAnimationOld.setAnimationListener(zoomAnimationListener);
        mZoomOutAnimationOld.setAnimationListener(zoomAnimationListener);
    }
}
 
源代码6 项目: Twire   文件: WelcomeActivity.java
private void startHideContinueIconAnimations() {
    Animation mScaleAnimation = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    Animation mRotateAnimation = new RotateAnimation(
            0, 360,
            Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f
    );
    mRotateAnimation.setRepeatCount(0);

    AnimationSet mAnimations = new AnimationSet(true);
    mAnimations.setDuration(REVEAL_ANIMATION_DURATION);
    mAnimations.setFillAfter(true);
    mAnimations.setInterpolator(new OvershootInterpolator(1.5f));
    mAnimations.addAnimation(mScaleAnimation);
    mAnimations.addAnimation(mRotateAnimation);

    mContinueIcon.startAnimation(mAnimations);
}
 
源代码7 项目: imsdk-android   文件: DailyNoteEditorActivity.java
public void startAnimation(View mView) {

        AlphaAnimation aa = new AlphaAnimation(0.4f, 1.0f); // 0完全透明 1 完全不透明
        // 以(0%,0.5%)为基准点,从0.5缩放至1
        ScaleAnimation sa = new ScaleAnimation(0.5f, 1, 0.5f, 1,
                Animation.RELATIVE_TO_SELF, 0,
                Animation.RELATIVE_TO_SELF, 0.5f);

        // 添加至动画集合
        AnimationSet as = new AnimationSet(false);
        as.addAnimation(aa);
        as.addAnimation(sa);
        as.setDuration(500);
        // 执行动画
        mView.startAnimation(as);
    }
 
源代码8 项目: faveo-helpdesk-android-app   文件: Fab.java
/**
 * Hides the FAB.
 */
@Override
public void hide() {
    // Only use scale animation if FAB is visible
    if (getVisibility() == View.VISIBLE) {
        // Pivots indicate where the animation begins from
        float pivotX = getPivotX() + getTranslationX();
        float pivotY = getPivotY() + getTranslationY();

        // Animate FAB shrinking
        ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, pivotX, pivotY);
        anim.setDuration(FAB_ANIM_DURATION);
        anim.setInterpolator(getInterpolator());
        startAnimation(anim);
    }
    setVisibility(View.INVISIBLE);
}
 
源代码9 项目: 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);
        }
    }
}
 
源代码10 项目: faveo-helpdesk-android-app   文件: Fab.java
/**
 * Hides the FAB.
 */
@Override
public void hide() {
    // Only use scale animation if FAB is visible
    if (getVisibility() == View.VISIBLE) {
        // Pivots indicate where the animation begins from
        float pivotX = getPivotX() + getTranslationX();
        float pivotY = getPivotY() + getTranslationY();

        // Animate FAB shrinking
        ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, pivotX, pivotY);
        anim.setDuration(FAB_ANIM_DURATION);
        anim.setInterpolator(getInterpolator());
        startAnimation(anim);
    }
    setVisibility(View.INVISIBLE);
}
 
@Test
public void animations() {
    ScaleAnimation animation = new ScaleAnimation(1f, 0f, 1f, 0f);
    AnimationViewBehavior behavior = new AnimationViewBehavior.Builder()
            .dependsOn(firstView.getId(), SimpleViewBehavior.DEPEND_TYPE_Y)
            .targetValue(100)
            .animation(animation)
            .build();

    CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(320, 200);
    params.setBehavior(behavior);
    secondView.setLayoutParams(params);

    ShadowAnimation shadowAnimation = Shadow.extract(animation);

    firstView.setY(50);
    coordinatorLayout.requestLayout();
    assertEquals(500L, shadowAnimation.getLastTimeGetTransform());

    firstView.setY(100);
    coordinatorLayout.requestLayout();
    assertEquals(1000L, shadowAnimation.getLastTimeGetTransform());
}
 
源代码12 项目: 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);
    }
}
 
源代码13 项目: RecyclerWheelPicker   文件: WheelPicker.java
public void doExitAnim(final View contentView, long animDuration) {
    if (builder.gravity == Gravity.BOTTOM) {
        ValueAnimator exitAnimator = ValueAnimator.ofFloat(0, contentView.getHeight());
        exitAnimator.setDuration(animDuration);
        exitAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float value = (float) animation.getAnimatedValue();
                contentView.setTranslationY(value);
            }
        });
        exitAnimator.start();
    } else {
        ScaleAnimation scaleAnimation = new ScaleAnimation(1.0F, 0.0F, 1.0F, 0.0F,
                Animation.RELATIVE_TO_PARENT, 0.5F, Animation.RELATIVE_TO_PARENT, 0.5F);
        scaleAnimation.setDuration(animDuration);
        scaleAnimation.setFillAfter(true);
        contentView.startAnimation(scaleAnimation);
    }
}
 
源代码14 项目: LLApp   文件: LoginActivity.java
private void start() {
    AnimationSet animationSet = new AnimationSet(true);
    ScaleAnimation scaleAnimation = new ScaleAnimation(
            1, 0.1f, 1, 0.1f,
            Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    scaleAnimation.setDuration(500);
    animationSet.addAnimation(scaleAnimation);
    animationSet.setFillAfter(true);
    animationSet.setFillBefore(false);
    animationSet.setRepeatCount(0);//设置重复次数
    portrait.startAnimation(scaleAnimation);
    new Handler().postDelayed(
            () -> portrait.setVisibility(View.GONE)
            , 500);
}
 
源代码15 项目: bither-android   文件: RawDataDiceView.java
public void deleteLast() {
    int size = data.size();
    if (size <= 0) {
        return;
    }
    data.remove(size - 1);
    final ImageView iv = (ImageView) ((FrameLayout) getChildAt(size - 1)).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);
        if (iv.getTag() != null && iv.getTag() instanceof HideIvRunnable) {
            iv.removeCallbacks((Runnable) iv.getTag());
        }
        HideIvRunnable r = new HideIvRunnable(iv);
        iv.setTag(r);
        iv.postDelayed(r, 300);
    }
}
 
源代码16 项目: Android-Basics-Codes   文件: MainActivity.java
/**
 * ���Ŷ���
 * 
 * @param v
 */
public void scale(View v) {

	/*
	 * ����1��x������ʼ��С(1f��ʾԭͼ��С) ����2��x������ֹ��С(0.2f��ʾԭͼ��0.2��)
	 * ����3��y������ʼ��С(1f��ʾԭͼ��С) ����4��y������ֹ��С(0.2f��ʾԭͼ��0.2��) ����5���������ĵ�x��ȡֵ�IJ��շ�ʽ
	 * ����6: ���ĵ�x���ȡֵ(0.5f��ʾ�����ԭͼ��0.5��) ����7���������ĵ�y��ȡֵ���շ�ʽ ����8:
	 * ���ĵ�y���ȡֵ(0.5f��ʾ�����ԭͼ��0.5��)
	 */
	ScaleAnimation rotate = new ScaleAnimation(4f, 0.2f, 4f, 0.2f,
			Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
			0.5f);

	// ������ʾʱ�䳤��
	rotate.setDuration(2000);
	// �����ظ�����
	rotate.setRepeatCount(2);
	// ���ö����ظ���ģʽ
	rotate.setRepeatMode(Animation.REVERSE);

	// ��ImageView�ϲ��Ŷ���
	iv.startAnimation(rotate);
}
 
源代码17 项目: Floo   文件: WebActivity.java
@Override
@SuppressLint("SetJavaScriptEnabled")
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_web);
  WebView webView = (WebView) findViewById(R.id.web_view);
  String url = getIntent().getStringExtra(URL);
  if (url == null && getIntent().getData() != null) {
    url = getIntent().getData().getQueryParameter(URL);
  }
  if (url == null) {
    finish();
  }
  webView.setWebViewClient(new InnerWebViewClient());
  webView.getSettings().setJavaScriptEnabled(true);
  webView.loadUrl(url);

  loading = (TextView) findViewById(R.id.loading);
  Animation animation = new ScaleAnimation(1.0f, 1.2f, 1.0f, 1.2f,
      Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
  animation.setRepeatMode(Animation.REVERSE);
  animation.setRepeatCount(Animation.INFINITE);
  animation.setDuration(500);
  loading.startAnimation(animation);
  setTitle(url);
}
 
/**
 * Assign a "scale to 120% and back bounce + fade out and in" animation to the given view
 * @param view the view to animate
 * @param duration duration of the animation
 */
public static void setBounceAnimatiom(View view, long duration){
    ScaleAnimation grow = new ScaleAnimation(1.0f, 1.2f, 1.0f, 1.2f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    grow.setDuration(duration);
    ScaleAnimation shrink = new ScaleAnimation(1.0f, 0.8f, 1.0f, 0.8f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    shrink.setDuration(duration);
    shrink.setStartOffset(duration);

    // Fade out then repeat to fade back in
    AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.3f);
    fadeOut.setInterpolator(new DecelerateInterpolator()); //and this
    fadeOut.setDuration(100);
    fadeOut.setRepeatMode(Animation.REVERSE);
    fadeOut.setRepeatCount(1);

    AnimationSet set = new AnimationSet(false);
    set.addAnimation(grow);
    set.addAnimation(shrink);
    set.addAnimation(fadeOut);
    view.startAnimation(set);
}
 
源代码19 项目: Paginize   文件: SquashPageAnimator.java
private void initAnimations() {
  DecelerateInterpolator interpolator = new DecelerateInterpolator(3.0f);
  mExpandInFromRightAnimation = new ScaleAnimation(0, 1, 1, 1,
      Animation.RELATIVE_TO_PARENT, 1, Animation.RELATIVE_TO_PARENT, 0);
  mExpandInFromRightAnimation.setInterpolator(interpolator);
  mExpandInFromRightAnimation.setDuration(ANIMATION_DURATION);

  mShrinkOutFromRightAnimation = new ScaleAnimation(1, 0, 1, 1,
      Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0);
  mShrinkOutFromRightAnimation.setInterpolator(interpolator);
  mShrinkOutFromRightAnimation.setDuration(ANIMATION_DURATION);

  mExpanndInFromLeftAnimation = new ScaleAnimation(0, 1, 1, 1,
      Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0);
  mExpanndInFromLeftAnimation.setInterpolator(interpolator);
  mExpanndInFromLeftAnimation.setDuration(ANIMATION_DURATION);

  mShrinkOutFromLeftAnimation = new ScaleAnimation(1, 0, 1, 1,
      Animation.RELATIVE_TO_PARENT, 1, Animation.RELATIVE_TO_PARENT, 0);
  mShrinkOutFromLeftAnimation.setInterpolator(interpolator);
  mShrinkOutFromLeftAnimation.setDuration(ANIMATION_DURATION);
}
 
源代码20 项目: mollyim-android   文件: HidingLinearLayout.java
public void show() {
  if (!isEnabled() || getVisibility() == VISIBLE) return;

  setVisibility(VISIBLE);

  AnimationSet animation = new AnimationSet(true);
  animation.addAnimation(new ScaleAnimation(0.5f, 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);
}
 
源代码21 项目: EasyPhotos   文件: EasyPhotosActivity.java
private void shouldShowMenuDone() {
    if (Result.isEmpty()) {
        if (View.VISIBLE == tvDone.getVisibility()) {
            ScaleAnimation scaleHide = new ScaleAnimation(1f, 0f, 1f, 0f);
            scaleHide.setDuration(200);
            tvDone.startAnimation(scaleHide);
        }
        tvDone.setVisibility(View.INVISIBLE);
        tvPreview.setVisibility(View.INVISIBLE);
    } else {
        if (View.INVISIBLE == tvDone.getVisibility()) {
            ScaleAnimation scaleShow = new ScaleAnimation(0f, 1f, 0f, 1f);
            scaleShow.setDuration(200);
            tvDone.startAnimation(scaleShow);
        }
        tvDone.setVisibility(View.VISIBLE);
        tvPreview.setVisibility(View.VISIBLE);
    }
    if (Setting.distinguishCount && Setting.selectMutualExclusion && Result.photos.size() > 0) {
        final String photoType = Result.photos.get(0).type;
        if (photoType.contains(Type.VIDEO) && Setting.videoCount != -1) {
            tvDone.setText(getString(R.string.selector_action_done_easy_photos, Result.count(), Setting.videoCount));
        } else if (photoType.contains(Type.IMAGE) && Setting.pictureCount != -1) {
            tvDone.setText(getString(R.string.selector_action_done_easy_photos, Result.count(), Setting.pictureCount));
        } else {
            tvDone.setText(getString(R.string.selector_action_done_easy_photos, Result.count(), Setting.count));
        }
    } else {
        tvDone.setText(getString(R.string.selector_action_done_easy_photos, Result.count(), Setting.count));
    }
}
 
源代码22 项目: bcm-android   文件: VoiceRecodingPanel.java
private void hide(float x) {
    this.lastPositionX = x;

    float offset = getOffset(x);
    int widthAdjustment = getWidthAdjustment();

    AnimationSet animation = new AnimationSet(false);
    Animation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);

    Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, offset + widthAdjustment,
            Animation.ABSOLUTE, widthAdjustment,
            Animation.RELATIVE_TO_SELF, -.25f,
            Animation.RELATIVE_TO_SELF, -.25f);

    scaleAnimation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));
    translateAnimation.setInterpolator(new DecelerateInterpolator());
    animation.addAnimation(scaleAnimation);
    animation.addAnimation(translateAnimation);
    animation.setDuration(ANIMATION_DURATION);
    animation.setFillBefore(true);
    animation.setFillAfter(false);
    animation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));

    recordButtonFab.setVisibility(View.GONE);
    recordButtonFab.clearAnimation();
    recordButtonFab.startAnimation(animation);
}
 
源代码23 项目: droidconat-2016   文件: Animations.java
public static void scale(View view, float ratioFrom, float ratioTo, long durationMillis) {
    ScaleAnimation anim = new ScaleAnimation(ratioFrom, ratioTo, ratioFrom, ratioTo, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    anim.setFillBefore(true);
    anim.setFillAfter(true);
    anim.setFillEnabled(true);
    anim.setDuration(durationMillis);
    anim.setInterpolator(new OvershootInterpolator());
    view.startAnimation(anim);
}
 
源代码24 项目: Study_Android_Demo   文件: MainActivity.java
public void scaleAnim_java(View view) {
	// 2.����һ��ScaleAnimation����
	ScaleAnimation animation = new ScaleAnimation(1f, 3f, 1f, 3f,
			ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
			ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
	// ����ʱ��
	animation.setDuration(1000);
	// ����ֹͣ�����һ֡
	animation.setFillAfter(true);
	// 3.���Ŷ���
	iv_rocket.startAnimation(animation);

}
 
源代码25 项目: KJFrameForAndroid   文件: KJAnimations.java
/**
 * 缩放 Scale
 */
public static Animation getScaleAnimation(float scaleXY, long durationMillis) {
    ScaleAnimation scale = new ScaleAnimation(1.0f, scaleXY, 1.0f, scaleXY,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);
    scale.setDuration(durationMillis);
    return scale;
}
 
源代码26 项目: 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();
    }
}
 
源代码27 项目: DevUtils   文件: AnimationUtils.java
/**
 * 获取一个中心点缩放动画
 * @param fromX             动画开始前在 X 坐标
 * @param toX               动画结束后在 X 坐标
 * @param fromY             动画开始前在 Y 坐标
 * @param toY               动画结束后在 Y 坐标
 * @param durationMillis    动画持续时间
 * @param animationListener 动画监听器
 * @return 一个中心点缩放动画
 */
public static ScaleAnimation getScaleAnimationCenter(final float fromX, final float toX, final float fromY, final float toY,
                                                     final long durationMillis, final AnimationListener animationListener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(fromX, toX, fromY, toY,
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
    scaleAnimation.setDuration(durationMillis);
    if (animationListener != null) {
        scaleAnimation.setAnimationListener(animationListener);
    }
    return scaleAnimation;
}
 
源代码28 项目: 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);
}
 
源代码29 项目: android-recipes-app   文件: FragmentManager.java
static Animation makeOpenCloseAnimation(Context context, float startScale,
        float endScale, float startAlpha, float endAlpha) {
    AnimationSet set = new AnimationSet(false);
    ScaleAnimation scale = new ScaleAnimation(startScale, endScale, startScale, endScale,
            Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f);
    scale.setInterpolator(DECELERATE_QUINT);
    scale.setDuration(ANIM_DUR);
    set.addAnimation(scale);
    AlphaAnimation alpha = new AlphaAnimation(startAlpha, endAlpha);
    alpha.setInterpolator(DECELERATE_CUBIC);
    alpha.setDuration(ANIM_DUR);
    set.addAnimation(alpha);
    return set;
}
 
源代码30 项目: mappwidget   文件: MapWidget.java
private Animation getZoomInAnimation(float pivotX, float pivotY) {
	float fromX = 1.0f;
	float fromY = 1.0f;
	float toX = 2.0f;
	float toY = 2.0f;

	Animation zoomInAnimation = new ScaleAnimation(fromX, toX, fromY, toY,
			pivotX, pivotY);
	zoomInAnimation.setDuration(500);
	zoomInAnimation.setInterpolator(decelerateInterpolator);
	zoomInAnimation.setFillAfter(true);

	return zoomInAnimation;
}