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

The following examples show how to use android.view.animation.ScaleAnimation#setInterpolator() . 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: 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 2
Source File: Utils.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
public static Animation createScaleAnimation(View view, int parentWidth, int parentHeight,
        int toX, int toY) {
    // Difference in X and Y
    final int diffX = toX - view.getLeft();
    final int diffY = toY - view.getTop();

    // Calculate actual distance using pythagors
    float diffDistance = FloatMath.sqrt((toX * toX) + (toY * toY));
    float parentDistance = FloatMath
            .sqrt((parentWidth * parentWidth) + (parentHeight * parentHeight));

    ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 0f, 1f, 0f, Animation.ABSOLUTE,
            diffX,
            Animation.ABSOLUTE, diffY);
    scaleAnimation.setFillAfter(true);
    scaleAnimation.setInterpolator(new DecelerateInterpolator());
    scaleAnimation.setDuration(Math.round(diffDistance / parentDistance
            * Constants.SCALE_ANIMATION_DURATION_FULL_DISTANCE));

    return scaleAnimation;
}
 
Example 3
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 4
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 5
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 6
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 7
Source File: FragmentManager.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 8
Source File: ViewAnimationUtil.java    From SimpleProject with MIT License 5 votes vote down vote up
public static void scale(View view, int fromX, int toX, int fromY, int toY, int duration, Interpolator interpolator) {
	ScaleAnimation animation = new ScaleAnimation(fromX, toX, fromY, toY);
	animation.setDuration(duration);
	animation.setFillAfter(true);
	animation.setInterpolator(interpolator);
	view.startAnimation(animation);
}
 
Example 9
Source File: FragmentManager.java    From guideshow with MIT License 5 votes vote down vote up
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;
}
 
Example 10
Source File: ViewUtils.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void demoteView(final View view, boolean isAnimated) {
    if (view == null) {
        return;
    }

    if (isAnimated) {
        ScaleAnimation scaleAnimation = new ScaleAnimation(1.1f, 1.0f, 1.1f, 1.0f, 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 11
Source File: FragmentManager.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
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;
}
 
Example 12
Source File: MapActions.java    From PocketMaps with MIT License 5 votes vote down vote up
/**
 * start button: control button handler FAB
 */

private void initControlBtnHandler() {
    final ScaleAnimation anim = new ScaleAnimation(0, 1, 0, 1);
    anim.setFillBefore(true);
    anim.setFillAfter(true);
    anim.setFillEnabled(true);
    anim.setDuration(300);
    anim.setInterpolator(new OvershootInterpolator());

    controlBtn.setOnClickListener(new View.OnClickListener() {
        @Override public void onClick(View v) {
            if (isMenuVisible()) {
                setMenuVisible(false);
                sideBarMenuVP.setVisibility(View.INVISIBLE);
                favourBtn.setVisibility(View.INVISIBLE);
                settingsBtn.setVisibility(View.INVISIBLE);
                controlBtn.setImageResource(R.drawable.ic_keyboard_arrow_up_white_24dp);
                controlBtn.startAnimation(anim);
            } else {
                setMenuVisible(true);
                sideBarMenuVP.setVisibility(View.VISIBLE);
                favourBtn.setVisibility(View.VISIBLE);
                settingsBtn.setVisibility(View.VISIBLE);
                controlBtn.setImageResource(R.drawable.ic_keyboard_arrow_down_white_24dp);
                controlBtn.startAnimation(anim);
            }
        }
    });
}
 
Example 13
Source File: ScaleAnimEffect.java    From TvLauncher with Apache License 2.0 5 votes vote down vote up
public Animation createAnimation() {
    ScaleAnimation anim = new ScaleAnimation(fromXScale, toXScale, fromYScale, toYScale, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    anim.setFillAfter(true);
    anim.setInterpolator(new AccelerateInterpolator());
    anim.setDuration(duration);
    return anim;
}
 
Example 14
Source File: AltitudeFragment.java    From JayPS-AndroidApp with MIT License 5 votes vote down vote up
private void animateAltitudeBars(ImageView[] views, float[] displayValues) {

        for(int v =0; v < views.length;v++) {
            views[v].setMaxHeight(_view.getHeight());
            ScaleAnimation scale = new ScaleAnimation(1, 1, _prevValues[v], displayValues[v], Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 1.0f);
            scale.setFillAfter(true);
            scale.setDuration(500);
            scale.setInterpolator(new AccelerateInterpolator(1.0f));
            views[v].startAnimation(scale);
        }

        _prevValues = displayValues;

    }
 
Example 15
Source File: FragmentManager.java    From android-recipes-app with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 16
Source File: DSListView.java    From direct-select-android with MIT License 5 votes vote down vote up
private void showListView() {
    if (animationInProgress || scrollInProgress || listViewIsShown) return;
    listView.setEnabled(true);
    animationInProgress = true;

    this.setVisibility(View.VISIBLE);
    this.bringToFront();
    this.readyToHide = false;

    // Scale picker box if animations enabled
    if (selectorAnimationsEnabled && null != this.pickerBox) {
        ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 1f + scaleFactorDelta, 1f, 1f + scaleFactorDelta,
                Animation.RELATIVE_TO_SELF, selectorAnimationCenterPivot ? 0.5f : 0f, Animation.RELATIVE_TO_SELF, 0.5f);
        scaleAnimation.setInterpolator(new AccelerateInterpolator());
        scaleAnimation.setDuration(100);
        scaleAnimation.setFillAfter(true);
        this.pickerBox.getCellRoot().startAnimation(scaleAnimation);
    }

    // Show picker view animation
    AlphaAnimation showAnimation = new AlphaAnimation(0f, 1f);
    showAnimation.setDuration(200);
    showAnimation.setInterpolator(new AccelerateInterpolator());
    showAnimation.setAnimationListener(new AnimationListenerAdapter() {
        @Override
        public void onAnimationEnd(Animation animation) {
            animationInProgress = false;
            listViewIsShown = true;
            hideListView();
        }
    });

    this.startAnimation(showAnimation);
}
 
Example 17
Source File: DSListView.java    From direct-select-android with MIT License 5 votes vote down vote up
private void hideListView() {
    if (!readyToHide || animationInProgress || scrollInProgress || !listViewIsShown || adapter == null) return;

    readyToHide = false;
    animationInProgress = true;
    listView.setEnabled(false);

    this.setVisibility(View.INVISIBLE);

    this.pickerBox.onSelect(adapter.getItem(selectedItem), selectedItem);

    AlphaAnimation hideAnimation = new AlphaAnimation(1f, 0f);
    hideAnimation.setStartOffset(subScrollDuration);
    hideAnimation.setDuration(200);
    hideAnimation.setInterpolator(new DecelerateInterpolator());
    hideAnimation.setAnimationListener(new AnimationListenerAdapter() {
        @Override
        public void onAnimationEnd(Animation animation) {
            listViewIsShown = false;
            animationInProgress = false;
        }
    });
    DSListView.this.startAnimation(hideAnimation);

    // Scale picker box text animation if animations enabled
    if (selectorAnimationsEnabled && null != this.pickerBox) {
        ScaleAnimation scaleAnimation = new ScaleAnimation(1f + scaleFactorDelta, 1f, 1f + scaleFactorDelta, 1f,
                Animation.RELATIVE_TO_SELF, selectorAnimationCenterPivot ? 0.5f : 0f, Animation.RELATIVE_TO_SELF, 0.5f);
        scaleAnimation.setInterpolator(new DecelerateInterpolator());
        scaleAnimation.setStartOffset(100 + subScrollDuration);
        scaleAnimation.setDuration(100);
        scaleAnimation.setFillAfter(true);
        this.pickerBox.getCellRoot().startAnimation(scaleAnimation);
    }
}
 
Example 18
Source File: FragmentManagerImpl.java    From letv with Apache License 2.0 5 votes vote down vote up
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, 1, 0.5f, 1, 0.5f);
    scale.setInterpolator(DECELERATE_QUINT);
    scale.setDuration(220);
    set.addAnimation(scale);
    AlphaAnimation alpha = new AlphaAnimation(startAlpha, endAlpha);
    alpha.setInterpolator(DECELERATE_CUBIC);
    alpha.setDuration(220);
    set.addAnimation(alpha);
    return set;
}
 
Example 19
Source File: RxAnimationTool.java    From RxTools-master with Apache License 2.0 5 votes vote down vote up
public static void ScaleUpDowm(View view) {
    ScaleAnimation animation = new ScaleAnimation(1.0f, 1.0f, 0.0f, 1.0f);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(1200);
    view.startAnimation(animation);
}
 
Example 20
Source File: ZoomInImageDisplayer.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);
}