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

The following examples show how to use android.view.animation.ScaleAnimation#setFillAfter() . 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: RawDataBinaryView.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);
        iv.postDelayed(new Runnable() {
            @Override
            public void run() {
                iv.setVisibility(View.INVISIBLE);
            }
        }, 300);
    }
}
 
Example 2
Source File: HeadImageView.java    From glass_snippets with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void setScaleFactor(float factor) {
  if (getAnimation() != null && !getAnimation().hasEnded())
    getAnimation().cancel();
  
  if (factor < 1)
    factor=1;
  
  deactivate();
  
  ScaleAnimation a = new ScaleAnimation(mScaleFactor, factor, mScaleFactor, factor,
      Animation.RELATIVE_TO_SELF, .5F, Animation.RELATIVE_TO_SELF, .5F);

  a.setDuration(500);
  a.setFillAfter(true);
  a.setFillEnabled(true);
  setAnimation(a);

  mScaleFactor = factor;
  MAX_SCROLL_X = MAX_SCROLL_Y = null;
  
  activate();
}
 
Example 3
Source File: Animation.java    From MusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
private void startAnimation(List<Interpolator> interpolatorList) {
    for (int i = 0; i < interpolatorList.size(); i++) {
        Interpolator interpolator = interpolatorList.get(i);
        View view = root.getChildAt(i);
        //   TranslateAnimation Tanimation = new TranslateAnimation(0, displaySize.x - maxTextWidth - 2 * margin, 0, 0);
        ScaleAnimation animation = new ScaleAnimation(2, 1, 2, 1);
        //    RotateAnimation animation = new RotateAnimation(0,60);
        animation.setFillAfter(true);
        //     Tanimation.setFillAfter(true);
        animation.setDuration(ANIMATION_DURATION);
        //   Tanimation.setDuration(ANIMATION_DURATION);
        if (interpolator != null) {
            animation.setInterpolator(interpolator);
            //    Tanimation.setInterpolator(pp_interpolator);
        }

        //    view.startAnimation(Tanimation);
        view.startAnimation(animation);
        //   view.setRotation(60);
    }
}
 
Example 4
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 5
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
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);

}
 
Example 6
Source File: AnimUtils.java    From star-zone-android with Apache License 2.0 5 votes vote down vote up
public static ScaleAnimation getScaleAnimation(float fromX, float toX, float fromY, float toY, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(fromX, toX, fromY, toY, pivotXType, pivotXValue, pivotYType, pivotYValue);
    scaleAnimation.setDuration(300L);
    scaleAnimation.setFillEnabled(true);
    scaleAnimation.setFillAfter(true);
    return scaleAnimation;
}
 
Example 7
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 8
Source File: Animations.java    From droidconat-2016 with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 9
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 10
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 11
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 12
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 13
Source File: EffectsButton.java    From Fatigue-Detection with MIT License 5 votes vote down vote up
ScaleAnimation createDownAnim() {
    ScaleAnimation localScaleAnimation = new ScaleAnimation(1.0F, 1.2F, 1.0F, 1.2F, 1, 0.5F, 1, 0.5F);
    localScaleAnimation.setDuration(50L);
    localScaleAnimation.setFillEnabled(true);
    localScaleAnimation.setFillBefore(false);
    localScaleAnimation.setFillAfter(true);
    return localScaleAnimation;
}
 
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: 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 16
Source File: VersionDiffUtils.java    From Gallery with Apache License 2.0 5 votes vote down vote up
public static void scaleX(View view, float f) {
    if (view == null)
        return;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        view.setScaleX(f);
    } else {
        ScaleAnimation animation =new ScaleAnimation(f, f, f, f, 
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
        animation.setDuration(0);
        animation.setFillAfter(true);
        view.startAnimation(animation);
    }
}
 
Example 17
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 18
Source File: CommonViewAnimationActivity.java    From Android-Animation-Set with Apache License 2.0 5 votes vote down vote up
private Animation getScaleAnimation() {
    ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 2f,
            1f, 2f,
            getWidth() / 2, getHeight() / 2);
    scaleAnimation.setDuration(2000);
    scaleAnimation.setRepeatCount(2);
    scaleAnimation.setFillAfter(true);
    scaleAnimation.setFillBefore(false);
    scaleAnimation.setRepeatMode(Animation.REVERSE);
    return scaleAnimation;
}
 
Example 19
Source File: AnimationUtil.java    From Socket.io-FLSocketIM-Android with MIT License 5 votes vote down vote up
/**缩放
 * @param view
 * @param from 缩放开始比例0-1.0
 * @param to 缩放结束比例0-1.0
 * @param w
 * @param h
 */
public static void setViewScale(View view, float from, float to, int w, int h) {
    if (isAnimation) {
        ScaleAnimation animation = new ScaleAnimation(from, to, from, to,
                w/2, h/2);
        animation.setDuration(200);
        animation.setFillAfter(true);
        view.clearAnimation();
        view.setAnimation(animation);
        animation = null;
        System.gc();
    }
}
 
Example 20
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;
}