android.view.animation.ScaleAnimation Java Examples

The following examples show how to use android.view.animation.ScaleAnimation. 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: MicrophoneRecorderView.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: RawDataDiceView.java    From bither-android with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example #3
Source File: Fab.java    From faveo-helpdesk-android-app with Open Software License 3.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #4
Source File: LoginActivity.java    From LLApp with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: WheelPicker.java    From RecyclerWheelPicker with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example #6
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 #7
Source File: MainActivity.java    From Android-Basics-Codes with Artistic License 2.0 6 votes vote down vote up
/**
 * ���Ŷ���
 * 
 * @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);
}
 
Example #8
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 #9
Source File: AnimationViewBehaviorTest.java    From simple-view-behavior with MIT License 6 votes vote down vote up
@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());
}
 
Example #10
Source File: WebActivity.java    From Floo with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #11
Source File: DailyNoteEditorActivity.java    From imsdk-android with MIT License 6 votes vote down vote up
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);
    }
 
Example #12
Source File: WelcomeActivity.java    From Twire with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #13
Source File: Fab.java    From faveo-helpdesk-android-app with Open Software License 3.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #14
Source File: MapController.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example #15
Source File: ViewAnimation.java    From geopackage-mapcache-android with MIT License 6 votes vote down vote up
/**
 * 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);
}
 
Example #16
Source File: VoiceRecodingPanel.java    From bcm-android with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #17
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 #18
Source File: SquashPageAnimator.java    From Paginize with MIT License 6 votes vote down vote up
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);
}
 
Example #19
Source File: Fab.java    From material-sheet-fab with MIT License 6 votes vote down vote up
/**
 * 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);
}
 
Example #20
Source File: MyLayoutAnimationHelper.java    From RecyclerViewAnimation with Apache License 2.0 5 votes vote down vote up
/**
 * 放大动画
 *
 * @return
 */
public static AnimationSet getAnimationSetScaleBig() {
    AnimationSet animationSet = new AnimationSet(true);

    ScaleAnimation scaleAnimation = new ScaleAnimation(0.1f, 1.0f, 0.1f, 1.0f, RELATIVE_TO_SELF, 0.5f, RELATIVE_TO_SELF, 0.5f);
    scaleAnimation.setInterpolator(new DecelerateInterpolator());
    scaleAnimation.setDuration(400);


    animationSet.addAnimation(scaleAnimation);
    animationSet.setDuration(400);

    return animationSet;
}
 
Example #21
Source File: MainActivity.java    From android-mvp-architecture with Apache License 2.0 5 votes vote down vote up
@Override
public void reloadQuestionnaire(List<Question> questionList) {
    refreshQuestionnaire(questionList);
    ScaleAnimation animation =
            new ScaleAnimation(
                    1.15f, 1, 1.15f, 1,
                    Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);

    mCardsContainerView.setAnimation(animation);
    animation.setDuration(100);
    animation.start();
}
 
Example #22
Source File: PinLockAdapter.java    From lock-screen with MIT License 5 votes vote down vote up
private Animation scale(){
    ScaleAnimation scaleAnimation = new ScaleAnimation(.75F, 1f, .75F, 1f,
            Animation.RELATIVE_TO_SELF, .5F, Animation.RELATIVE_TO_SELF, .5F);
    scaleAnimation.setDuration(BUTTON_ANIMATION_DURATION);
    scaleAnimation.setFillAfter(true);
    return  scaleAnimation;
}
 
Example #23
Source File: WaveActivity.java    From ClockView with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_wave);
    scaleAnimation = new ScaleAnimation(1.2f, 1f, 1.2f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scaleAnimation.setDuration(500);
    scaleAnimation.setFillAfter(true);
    wave = (WaveView) findViewById(R.id.wave);
    head = (ImageView) findViewById(R.id.head);
    mPlayer = MediaPlayer.create(this, R.raw.water_wave);
    head.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            wave.addWave();
            head.startAnimation(scaleAnimation);
            if(mPlayer.isPlaying()){
                mPlayer.stop();
                try {
                    mPlayer.prepare();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            mPlayer.start();
        }
    });
    wave.start();
}
 
Example #24
Source File: VideoButtonView.java    From Android with MIT License 5 votes vote down vote up
private Animation getAnimScale(float toX, float toY) {
    Animation scaleAnimation = new ScaleAnimation(1f, toX, 1f, toY,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scaleAnimation.setFillAfter(true);
    scaleAnimation.setDuration(200);
    return scaleAnimation;
}
 
Example #25
Source File: RippleView.java    From ZDepthShadow 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 #26
Source File: KJAnimations.java    From CoreModule with Apache License 2.0 5 votes vote down vote up
/**
 * 缩放 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;
}
 
Example #27
Source File: PickerBitmapView.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onSelectionStateChange(List<PickerBitmap> selectedItems) {
    updateSelectionState();

    if (!isPictureTile()) return;

    boolean selected = selectedItems.contains(mBitmapDetails);
    boolean checked = super.isChecked();

    // In single-selection mode, the list needs to be updated to account for items that were
    // checked before but no longer are (because something else was selected).
    if (!mCategoryView.isMultiSelectAllowed() && !selected && checked) {
        super.toggle();
    }

    boolean needsResize = selected != checked;
    int size = selected && !checked ? mCategoryView.getImageSize() - 2 * mBorder
                                    : mCategoryView.getImageSize();
    if (needsResize) {
        float start;
        float end;
        if (size != mCategoryView.getImageSize()) {
            start = 1f;
            end = 0.8f;
        } else {
            start = 0.8f;
            end = 1f;
        }

        Animation animation = new ScaleAnimation(
                start, end, // Values for x axis.
                start, end, // Values for y axis.
                Animation.RELATIVE_TO_SELF, 0.5f, // Pivot X-axis type and value.
                Animation.RELATIVE_TO_SELF, 0.5f); // Pivot Y-axis type and value.
        animation.setDuration(ANIMATION_DURATION);
        animation.setFillAfter(true); // Keep the results of the animation.
        mIconView.startAnimation(animation);
    }
}
 
Example #28
Source File: AnimationHelper.java    From AnimatedPullToRefresh-master with Apache License 2.0 5 votes vote down vote up
private void addLoopScaleAnimations(long duration, AnimationSet set) {
    ScaleAnimation mScaleAnim = new ScaleAnimation(1, SCALE_AMOUNT, 1f, SCALE_AMOUNT, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mScaleAnim.setDuration(duration);
    set.addAnimation(mScaleAnim);
    ScaleAnimation mScaleDownAnim = new ScaleAnimation(SCALE_AMOUNT, 1, SCALE_AMOUNT, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mScaleDownAnim.setDuration(duration);
    mScaleDownAnim.setStartOffset(duration + 50);
    set.addAnimation(mScaleDownAnim);
    set.setInterpolator(interpolator);
}
 
Example #29
Source File: AnimationUtils.java    From XKnife-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Anim rotate scale show view. 旋转放大动画
 *
 * @param iv the iv
 */
public static void animRotateScaleShowView(ImageView iv) {
    AnimationSet set = new AnimationSet(true);
    // 旋转动画
    RotateAnimation ra = new RotateAnimation(0, 180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    ra.setDuration(120);
    // 缩放动画
    ScaleAnimation sa = new ScaleAnimation(0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    sa.setDuration(120);
    // 向集合中添加动画
    set.addAnimation(ra);
    set.addAnimation(sa);
    iv.startAnimation(set);
}
 
Example #30
Source File: AttachmentTypeSelector.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
private void animateButtonIn(View button, int delay) {
  AnimationSet animation = new AnimationSet(true);
  Animation scale = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f,
                                       Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.0f);

  animation.addAnimation(scale);
  animation.setInterpolator(new OvershootInterpolator(1));
  animation.setDuration(ANIMATION_DURATION);
  animation.setStartOffset(delay);
  button.startAnimation(animation);
}